By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,751 Members | 1,156 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,751 IT Pros & Developers. It's quick & easy.

Outputting an rtf to browser

P: n/a
Hi all, I'm just trying to send a rtf file to the browser but firefox
and IE just display raw rtf content (with tags and so on)...
I used this code down below:

--CODE

$length = strlen($new_rtf);

$filename = "certificato_".$paz.".rtf";

header("Content-Type: application/rtf");

header("Content-Length: ".$length);

header("Content-Disposition:attachment; filename=\"".$filename."\"");

echo($new_rtf);

--END

Actually it's in a page with no HTML tags, I don't know if this is an
error or what...Can anybody help me?
Aug 30 '08 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Peter:
header("Content-Type: application/rtf");
The registered MIME type for RTF is text/rtf.

http://www.iana.org/assignments/media-types/

--
Jock
Aug 30 '08 #2

P: n/a
John Dunlop ha scritto:
Peter:
> header("Content-Type: application/rtf");

The registered MIME type for RTF is text/rtf.

http://www.iana.org/assignments/media-types/

--
Jock
thank you so much, but still not works...I don't know why. Should I
put headers between <headhtml tags?
Aug 30 '08 #3

P: n/a
Peter schreef:
Hi all, I'm just trying to send a rtf file to the browser but firefox
and IE just display raw rtf content (with tags and so on)...
I used this code down below:

--CODE

$length = strlen($new_rtf);

$filename = "certificato_".$paz.".rtf";

header("Content-Type: application/rtf");

header("Content-Length: ".$length);

header("Content-Disposition:attachment; filename=\"".$filename."\"");

echo($new_rtf);

--END

Actually it's in a page with no HTML tags, I don't know if this is an
error or what...Can anybody help me?
you use '$filename' and '$new_rtf'

Which of them contains the file you want to send to the browser?

--
Luuk
Aug 30 '08 #4

P: n/a
Luuk ha scritto:
Peter schreef:
>Hi all, I'm just trying to send a rtf file to the browser but firefox
and IE just display raw rtf content (with tags and so on)...
I used this code down below:

--CODE

$length = strlen($new_rtf);

$filename = "certificato_".$paz.".rtf";

header("Content-Type: application/rtf");

header("Content-Length: ".$length);

header("Content-Disposition:attachment; filename=\"".$filename."\"");

echo($new_rtf);

--END

Actually it's in a page with no HTML tags, I don't know if this is an
error or what...Can anybody help me?

you use '$filename' and '$new_rtf'

Which of them contains the file you want to send to the browser?

$filename is just a string containing file's name, while $new_rtf is
the reference to the file
Aug 30 '08 #5

P: n/a
Peter schreef:
Luuk ha scritto:
>Peter schreef:
>>Hi all, I'm just trying to send a rtf file to the browser but firefox
and IE just display raw rtf content (with tags and so on)...
I used this code down below:

--CODE

$length = strlen($new_rtf);

$filename = "certificato_".$paz.".rtf";

header("Content-Type: application/rtf");

header("Content-Length: ".$length);

header("Content-Disposition:attachment; filename=\"".$filename."\"");

echo($new_rtf);

--END

Actually it's in a page with no HTML tags, I don't know if this is an
error or what...Can anybody help me?

you use '$filename' and '$new_rtf'

Which of them contains the file you want to send to the browser?


$filename is just a string containing file's name, while $new_rtf is the
reference to the file
1 <?php
2
3 $filename = "test.rtf";
4 $length = strlen($filename);
5 header("Content-Type: application/rtf");
6 header("Content-Length: ".$length);
7 header("Content-Disposition:attachment; filename=\"".$filename."\"");
8
9 echo($filename);
10
11 ?>

worked for me....

--
Luuk
Aug 30 '08 #6

P: n/a
Peter wrote:
Hi all, I'm just trying to send a rtf file to the browser but firefox
and IE just display raw rtf content (with tags and so on)...
I used this code down below:

--CODE

$length = strlen($new_rtf);

$filename = "certificato_".$paz.".rtf";

header("Content-Type: application/rtf");

header("Content-Length: ".$length);

header("Content-Disposition:attachment; filename=\"".$filename."\"");

echo($new_rtf);

--END

Actually it's in a page with no HTML tags, I don't know if this is an
error or what...Can anybody help me?
You can recommend dispositions, but the browser is free to ignore them.

However, in your case, I suspect something else is going on. First of
all, enable all errors and display them - in your php.ini file, put:

display_errors=on
error_reporting=E_ALL

And restart your web server.

If that doesn't show anything, look at the headers being sent by the web
server - the "Live HTTP Headers" add-on for Firefox is great in this
respect.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Aug 30 '08 #7

P: n/a
In article <48***********************@reader4.news.tin.it>,
Peter <zigozago@myhomewrote:
Hi all, I'm just trying to send a rtf file to the browser but firefox
and IE just display raw rtf content (with tags and so on)...
I used this code down below:

--CODE

$length = strlen($new_rtf);

$filename = "certificato_".$paz.".rtf";

header("Content-Type: application/rtf");

header("Content-Length: ".$length);

header("Content-Disposition:attachment; filename=\"".$filename."\"");

echo($new_rtf);

--END

Actually it's in a page with no HTML tags, I don't know if this is an
error or what...Can anybody help me?
What are you *expecting* to happen ??
Aug 30 '08 #8

P: n/a
Tim Streater ha scritto:
In article <48***********************@reader4.news.tin.it>,
Peter <zigozago@myhomewrote:
>Hi all, I'm just trying to send a rtf file to the browser but firefox
and IE just display raw rtf content (with tags and so on)...
I used this code down below:

--CODE

$length = strlen($new_rtf);

$filename = "certificato_".$paz.".rtf";

header("Content-Type: application/rtf");

header("Content-Length: ".$length);

header("Content-Disposition:attachment; filename=\"".$filename."\"");

echo($new_rtf);

--END

Actually it's in a page with no HTML tags, I don't know if this is an
error or what...Can anybody help me?

What are you *expecting* to happen ??
Solved. It was a problem of an html opening tag just at the beginning
of the file
Aug 30 '08 #9

This discussion thread is closed

Replies have been disabled for this discussion.