Delhaze
Fri 28th Sep '01, 4:15pm
When downloading attachments on NS 6.1 the filename is not passed correctly to the download, and is saved as attachment.php.
Delhaze
Fri 28th Sep '01, 7:58pm
I found this, thought it might be of use.
From mkknapp@quadrapod.com at php.net
http://www.php.net/manual/en/function.header.php
There has been a lot of posts saying different things about using
header("Content-Disposition: attachment; filename=yourfilename");
to download files in both Netscape and IE. So I did a a bit of testing and here are my conclusive results:
Netscape works, with the correct filename in the download dialog, only if you DO have the 'attachment;' keyword, like so:
header("Content-Disposition: attachment; filename=yourfilename");
Because of a known bug, which you can read about at http://support.microsoft.com/support/kb/articles/Q281/1/19.ASP, IE only downloads, with the correct filename in the download dialog, if you DO NOT have the 'attachment;' keyword, like so:
header("Content-Disposition: filename=yourfilename");
Since you do not want to inconvience one half of users or the other, you need to be able to do both. There are 2 methods to do this.
-- First Method (For quick and sleazy hackers):
header("Content-Disposition: atachment; filename=yourfilename");
Note the one 't' in attachment. This bug, but it works on BOTH browsers. I recommed you do NOT use this method, as it is very bad practice for your code to depend on a bug. If it gets fixed, like it should be, your code is now broken.
-- Second Method (For responsible code monkeys)
Detect the browser, and add attachment accordingly. Since IE is the only one with the bug, that I know of, just isolate it, like so:
if (strstr($HTTP_USER_AGENT,"MSIE"))
$attachment="";
else
$attachment=" attachment;";
header("Content-Disposition:$attachment filename=yourfilename");
Freddie Bingham
Sat 13th Oct '01, 1:32pm
Thanks for all the info, save me from doing the leg work :)
Powered by vBulletin™ Version 4.0.0 Beta 4 Copyright © 2009 vBulletin Solutions, Inc. All rights