Page 1 of 1

Whats wrong with this code?

Posted: Mon Jun 09, 2003 11:09 am
by Galt
Here is a file I use to let the user download a file:

Code: Select all

<?
//File: getfile.php
$filename = "gets_filename_from_database"; //ex: blah.zip
$filelocation = "gets_from_database"; //ex: ../blah.zip

header("Content-type: application/download");
header("Content-disposition: attachment; filename=".$filename);

readfile($filelocation);
?>
This code works perfectly fine in Mozilla 1.3, but doesn't in IE 5.x . I tried adding quotes to the filename ( ... filename =\"".$filename."\" .....), and it still wouldn't work in IE, but did with Mozilla.

Anybody know how to make it work in IE?

Posted: Mon Jun 09, 2003 11:55 am
by nightmatrix
I just tried running that script on my computer using IE 6.0 when I ran it, it gave me the option to download a file (I did'nt see any problem) maybe on older versions of IE this does'nt work

Anyway

Good Luck


Night Matrix

Andrew

Posted: Mon Jun 09, 2003 12:23 pm
by Galt
IE 5.x pops up a dialogue box as well, but it doesn't actually let you download the file. The popup window says "save file xxxxx", where xxxxx is not the what I specified in the filename="" parameter. Moreover, if you choose to open the file or save it, it then gives an error.

Posted: Mon Jun 09, 2003 3:10 pm
by m3rajk
umm....( ... filename =\"".$filename."\" .....)
if that's exactly what you tpped, there was an issue witht he html.


"\" should be \""

Posted: Mon Jun 09, 2003 5:35 pm
by qartis
Some versions of IE 5.x had a bug in which the header

Code: Select all

Content-disposition: attachment;
Needed to be spelled incorrectly:

Code: Select all

Content-disposition: atachment;

That may work.