note 36033 deleted from function.header by victor
| From: | victor@php.net | Date: | Sat, 27 Mar 2004 21:27:57 +0000 |
| Subject: | note 36033 deleted from function.header by victor | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-67259@lists.php.net to get a copy of this message | ||
Note Submitter: Liam
----
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.