Wednesday, May 19, 2010

SOLVED: How to open zip files in IE6

This one took some time to fix, but I got there in the end. Here's what worked for me...

Problem

The web app I was working on generated a CSV report on the fly, zipped it up and returned it to the user's browser.

When submitting the web form that generated the report, the user's browser asked if you want to open or save the file. Firefox (and I'm assuming all other decent browsers) had no problems either opening, or saving then opening the file.

IE6, however, likes to be different.

Saving the file, then opening it, no problem. Tring to open the file straight away, big problem. The zip file was empty!  Interestingly, the downloaded file was not to be found in IE6's temporary files flder either.

It turns out that this was a well known bug in IE6 that Microsoft just couldn't be bothered to fix. Probably because they have newer browsers out there. I mean, who would use IE6 given the chance?

The Solution

For me, at least, I managed to work around the issue. Taking in to account the advice I found here, it turns out that there was some code in the web app adding response headers, specificly: Cache-Control: max-age=1,no-store,must-revalidate.

After stopping the web app from adding this header if the Content-Type was for a zip file (e.g. application/zip, application/x-zip etc.) all worked well.

Phew.

I'm guessing, but it seems that choosing to open  the file 'streams' the data back to associated application (WinZip in my case) via the browser, which takes the http headers in to account, opposed to saving and opening from disk.

About...

This is the about stuff