Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

header force download problem with exe file

Status
Not open for further replies.

bont

Programmer
Joined
Sep 7, 2000
Messages
200
Location
US
I have been trying code similar to:


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-Transfer-Encoding: binary");
header("Content-Disposition: attachment; filename=".basename($filename).";");
header("Content-Length:". filesize($filename));
readfile("$filename");
exit();


I am using Opra and IE for testing. They both appear to act exactly the same. They will download an EXE file, and the downloaded file will have the same file size as the original, but there is still a difference in the file after downloading. The downloaded file does not retain the icon that the original EXE has, and the EXE will not execute properly. Does anyone have any idea why ZIP works fine, but EXE does not?

Some other specifics are:

1)The filesize attribute does not work due to my file being located on an ftp? (I'll have to pass it manually)

2)I have tried the octet setting already, no difference.

I am very confused at this point.
 
Have you tried just reducing the number of headers you're sending?

Code:
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.basename($filename).'"');
readfile($filename);



Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Your code worked, but I am unsure exactly why. My suspicions are either due to using the binary setting, or a little bit different wording of other settigs.

Thank you very much.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top