IE Force Download Issues

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
pennythetuff
Forum Newbie
Posts: 22
Joined: Sun Feb 19, 2006 6:05 pm
Location: Kokomo, Indiana

IE Force Download Issues

Post by pennythetuff »

I'm having force download issues in IE. I'm forcing the download of a CSV file. Whenever I choose open from the download prompt, and Excel opens I get an error saying that it can't find the file. It works fine in Firefox. It just seems like it's either saving it in one spot and looking for it in another, or it's just not saving it. Thanks in advance.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

code??
pennythetuff
Forum Newbie
Posts: 22
Joined: Sun Feb 19, 2006 6:05 pm
Location: Kokomo, Indiana

Post by pennythetuff »

Here's my code:

Code: Select all

header("Pragma: public");
header("Cache-Control: private", false);
header("Content-Type: application/force-download");
header("Content-Disposition: attachment; filename=\"airvoyance.csv\";");
header("Content-Transfer-Encoding: binary");
readfile($filepath);
pennythetuff
Forum Newbie
Posts: 22
Joined: Sun Feb 19, 2006 6:05 pm
Location: Kokomo, Indiana

Post by pennythetuff »

The problem was I just wasn't paying attention. In the header:

Code: Select all

header("Content-Disposition: attachment; filename=\"airvoyance.csv\";");
Notice that I have quotes around the filename. I just removed those and it worked fine. Here's the fix:

Code: Select all

header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=airvoyance.csv;");
readfile($filepath);
I guess I'll just have to pay more attention next time. Thanks everyone.
Post Reply