Initiating a file download problems
Posted: Wed Apr 07, 2004 12:22 pm
I found some code a while back, I believe at php.net, that forces a download. I've been having problems getting Netscape to handle it correctly. For some reason it adds the extension .php to the .exe file that it is downloading. It works fine in Internet Explorer.
Here's the code:
I'm now using the more simple method of just giving a direct link to it, which works in IE as normal. It also works in NS, but doesn't give the option to save or open, like it did using the above code.
Basically, I want it to open the dialog box with the choice to save or open, and not add .php to the filename under Netscape. Anyone else have this problem, and know how to solve it?
Here's the code:
Code: Select all
<?php
$DLFile = 'http://www.abcdefg.com/file/whatever.exe';
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Disposition: attachment; filename=".basename($DLFile).";");
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($DLFile));
readfile("$DLFile");
exit();
?>Basically, I want it to open the dialog box with the choice to save or open, and not add .php to the filename under Netscape. Anyone else have this problem, and know how to solve it?