Internet Explorer removes .exe extension from down

2019-04-21 03:54发布

问题:

I am serving files from Amazon S3 now, and I generate a secure URL using the API. Works great everywhere except for people downloading .exe files in IE. I have tested this on IE 8 and 7.

If running a local webserver you can test by putting notepad.exe in your web root. Go to http://localhost/notepad.exe (or equivalent) Now try http://localhost/notepad.exe?

It should save the file as notepad, without extension. Is this a 'feature' because googling it is coming up with nothing. Thanks to the whole issue of IE extensions, you can't search for anything on file extensions.

Also, if the file has multiple periods in the name, it sometimes gets a [1] or [] added to the end.

Any ideas? Docs on this terrible behavior? It seems like it must be a security feature, but I have yet to find an option to disable it.

And as always, thank you. Tim

回答1:

There's a long story here, but the simple workaround is to do this:

http://www.example.com/dl/test.exe?mysecret=12321412&FixForIE=.exe

As for the trailing [1] or whatnot, no, there's not really anything you can do about that if the user happens to have downloaded from that URL before.



回答2:

We had the same problem when serving files from S3. Turns out you need to set the content-disposition correctly for IE to handle the files correctly. Namely, the HTTP header

Content-Disposition: attachment; filename="text.exe"

This article describes in a little more detail: http://www.jtricks.com/bits/content_disposition.html