Jump to content

Recommended Posts

Hi all,

 

I've got a script that zips some files and forces a download. In Firefox both opening and saving from the download dialog works fine. In IE, it works fine if I save it my desktop and then open the zip file, but if I try to open it from the directly from the dialog box I get an error saying that the compressed file is corrupted. This only seems to happen when working off our live server - i.e. not locally (even though both servers are running exactly the same software). These are the headers I'm using to force the download:

 

header("Pragma: public"); // required

header("Expires: 0");

header("Cache-Control: must-revalidate, post-check=0, pre-check=0");

header("Cache-Control: private",false); // required for certain browsers

header("Content-Transfer-Encoding: binary");

header("Content-Type: application/zip");

header("Content-Disposition: attachment; filename=\"".$listVersion.'.zip'."\";" );

header("Content-Transfer-Encoding: binary");

header("Content-Length: ".filesize($filename));

readfile($filename);

 

Can anyone help me with this?

 

Thanks,

 

hof

Link to comment
https://forums.phpfreaks.com/topic/84851-force-download-and-ie/
Share on other sites

As it turns out the problem was that the zip file was being gzipped with mod_deflate. This is the header that I'm receiving:

 

Expires: Thu, 19 Nov 1981 08:52:00 GMT

Cache-Control: must-revalidate, post-check=0, pre-check=0, private

Pragma: public

Content-Transfer-Encoding: binary

content-disposition: attachment; filename="145.zip";

Content-Length: 187613

Content-Encoding: gzip

Vary: Accept-Encoding

Keep-Alive: timeout=15, max=100

Connection: Keep-Alive

Content-Type: application/zip

 

I altered my apache configuration to ignore gzipping zip files (and others) with the following line:

SetEnvIfNoCase Request_URI \

        \.(?:gif|jpe?g|png|zip|pdf|swf)$ no-gzip dont-vary

 

 

However, I'm still getting a gzipped zip file.

 

Any ideas?

 

 

Link to comment
https://forums.phpfreaks.com/topic/84851-force-download-and-ie/#findComment-432642
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.