Whats wrong with this code?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Galt
Forum Newbie
Posts: 18
Joined: Thu May 22, 2003 8:08 am

Whats wrong with this code?

Post 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?
nightmatrix
Forum Newbie
Posts: 21
Joined: Sun Jun 08, 2003 11:03 am

Post 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
Galt
Forum Newbie
Posts: 18
Joined: Thu May 22, 2003 8:08 am

Post 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.
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

umm....( ... filename =\"".$filename."\" .....)
if that's exactly what you tpped, there was an issue witht he html.


"\" should be \""
qartis
Forum Contributor
Posts: 271
Joined: Sat Dec 14, 2002 4:43 pm
Location: BC, Canada
Contact:

Post 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.
Post Reply