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.


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.

  • Thanks, I'll give that a try. I'd prefer a server-side solution if possible.
    – Wilka
    Jul 15 '09 at 12:32
  • How to set the MIME declaration for a server like JBoss ?
    – Ved
    Feb 20 '12 at 9:46
  • 2
    It's actually more complicated than that. If you send the MIME as application/octet-stream, IE will sniff the "PK" at the head of the file and say, oh, the server didn't know what this was, so it gave me a generic application/octet-stream MIME type. But I know that a file starting with PK is probably a ZIP file, so I'll rename it. To avoid running into a problem like that, serve the file with a MIME type that's NOT application/octet-stream. Instead send, e.g. application/x-not-a-ZIP
    – EricLaw
    Aug 27 '12 at 22:21

Are you using IE8 to download it? If so you need to add the site to the trusted site list in IE8 for it to download properly.

  • Ah, yes - I should have been more specific that this is with IE8
    – Wilka
    Jul 15 '09 at 11:09

Appearently Internet Explorer 8 obeys the MIME type specified by the server for security reasons when naming a file.

You could try to configure your server's mime types and add 'xyz' (replace with your file extension) or to deactivate this behavior in Internet Explorer 8:

    Internet Options -> Security Settings
       "Custom Level" -> Miscellaneous section: 
       Open files based on content, not file extension

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.