Stretchwickster
Programmer
I'm using the following code to serve up exe files as downloads on a site:
The exe downloads ok (i.e. the file that is downloaded matches the filesize of the file on the server). The exe is actually a WinZip Self-Extractor executable file. When I run it, it shows a black console screen for about 0.5 second then does nothing.
If I type the URL of the file in the browser and download the file directly, the file is represented by a WinZip icon once downloaded and, when clicked, displays a WinZip Self-Extractor dialog as expected.
Does anyone know what is causing this discrepancy? I presume I'm doing something incorrectly when sending the headers?!
Your advice would be much appreciated!
Clive
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"To err is human, but to really foul things up you need a computer." (Paul Ehrlich)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To get the best answers from this forum see: faq102-5096
Code:
$filename = 'Update123.exe';
$mimetype = 'application/octet-stream';
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 5') or strpos($_SERVER['HTTP_USER_AGENT'], 'Opera 7')) {
$mimetype = 'application/x-download';
}
header('content-disposition: attachment; filename=' . $filename);
header('content-type: ' . $mimetype);
header('content-length: ' . filesize($downloads_path . $filename));
readfile($downloads_path . $filename);
If I type the URL of the file in the browser and download the file directly, the file is represented by a WinZip icon once downloaded and, when clicked, displays a WinZip Self-Extractor dialog as expected.
Does anyone know what is causing this discrepancy? I presume I'm doing something incorrectly when sending the headers?!
Your advice would be much appreciated!
Clive
![Runner_1Revised.gif](http://www.slydance.com/images/Runner_1Revised.gif)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"To err is human, but to really foul things up you need a computer." (Paul Ehrlich)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To get the best answers from this forum see: faq102-5096