Re: Filename problem with file downloading
| From: | Ernest E Vogelsinger | Date: | Mon, 26 May 2003 08:31:16 +0000 |
| Subject: | Re: Filename problem with file downloading | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-148964@lists.php.net to get a copy of this message | ||
At 08:15 26.05.2003, Alex Shi said:
--------------------[snip]--------------------
>Yes I used IE to test the script. However If tested from NS it would added
>a .php as ext. Both IE and NS will change filename if there're three
>segments
>in the filename (two-segment like filename.ext will be OK). Headaque!
--------------------[snip]--------------------
What are the exact headers you are sending for the downloaded file?
For downloadable files I always use this construct, and AFAIK it works with
IE as well as Netscape:
header('Content-Type: application/octet-stream');
header('Content-Length: ' . strlen($filecontents));
header('Content-Disposition: attachment' .
(empty($fname) ? '' : ';filename="'.$fname.'"'));
echo $filecontents;
exit();
This results in these headers being sent:
Content-Type: application/octet-stream
Content-Length: ###
Content-Disposition: attachment;filename="myfile.txt"
Note that the "filename" part in the last line must be enclosed in double
quotation marks to be recognized by all browsers (AFAIK the RFC doesn't
dictate this but some browsers may require it...)
--
>O Ernest E. Vogelsinger
(\) ICQ #13394035
^ http://www.vogelsinger.at/