note 36033 added to function.header
| From: | Liam at rn2 dot php dot net | Date: | Tue, 23 Sep 2003 15:22:00 +0000 |
| Subject: | note 36033 added to function.header | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-56981@lists.php.net to get a copy of this message | ||
Forcing a browser to download a text document is not easy to do correctly, especially on both Macs
and PCs. This was found to download a text file (not display it inline) on Internet Explorer,
Navigator, and Mozilla on a PC running Windows 95, and Macs running OS9.1 and OSX.
<?php
$Buffer='This is some file content';
header('Content-type: text/richtext; charset=UTF-8');
header('Content-Length: '.strlen($Buffer) );
header('Content-Disposition: attachment; filename="SalesReport.txt"');
echo $Buffer;
?>
All headers are required for maximum portability. Notice that even this is incorrect, as Macs may
treat files oddly, since they are declared as RTFs.
----
Manual Page -- http://www.php.net/manual/en/function.header.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+36033
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+36033&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+36033&report=yes