Stop IE8 renaming files to .zip when downloading

internet-explorer-8

We have some files on our web server, which are valid zip files but are used by another program as data files. However, when downloading these files (by clicking on an href link) with Internet Explorer 8 they get renamed to *.zip so they are no longer associated with the correct program.

Is there something I can do on our webserver, or the html of the download page, that will stop IE from renaming these files?

FireFox and Chrome leave the file with its original name, so doesn't have this problem.

Best Answer

First some background..

Your web server is determining that the file is a valid ZIP archive by using some MIME magic. So it delivers the HTTP response with the following header:

Content-Type: application/zip

When IE8 receives the file it has already been told that it is a ZIP. Then, when in it's default security setting of "Open files based on content, not file extension", it looks up a designated extension for that content type from the registry at HKEY_CLASSES_ROOT\MIME\Database\Content Type.

There are a couple of ways that you could attack this. You could amend either of the two variables on the local machine above. But I certainly wouldn't recommend changing local machine settings wherever possible - it's hackish and won't scale. The best solution would be to amend the web server either by:

  • Setting up a static MIME declaration for the file's original extension to be sent as application/octet-stream. This will prompt the file to be deliver as straight binary, with no content information.

  • Serving the files with the header Content-Disposition: attachment which will cause IE to respect the filename specified by the web server. This may not be so simple depending on your platform though.