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:
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.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.
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: