开发者

IE6 "helpfully" appends suffix to downloaded file

A webapp I've been developing allows users to upload and download a type of file which is meant to be treated as an opaque blob. My app serves it up with a file extension not commonly used for any other purpose, as well as specifying that its MIME Content-Type is application/octet-stream.

Internally, the file is a simple Zip archive containing a single compressed file. What I've found is that IE6 apparently inspects the content of the file, determines that it's a Zip archive, and "helpfully" saves it with an additional ".zip" extension. Unbelievable!

As I mentioned, this file is meant to be opaque, and we don't want users to be poking around inside the file--not because it's dangerous or contains sensitive information or anything, we just don't want to confuse them. I suggested prepending the Zip content with a magic number to prevent IE6 from recognizing it, but my manager says he'd prefer it if the file content could remain unchanged, so that knowledgeable people can rename the file and examine its contents as a zip archive, if necessary.

Is there any way to tell IE6 to keep its mitts off of t开发者_StackOverflowhe file? Or any alternative approach at all? (Alas, just not supporting IE6 at all is not an option.)

Incidentally, IE7 respects the file's name, but still identifies it as a Zip archive in the download dialog. That's better than IE6, but still less than ideal.


Short answer: Add correct MIME types to you web server so IE6 doesn't guess the file type.

Long Answer:

My work had a similar problem with Microsoft PowerPoint files.

.ppt vs .pps - Which are identical files with different extensions. We wanted the user to view a show (.pps) but IE6 kept changing it to .ppt. It changed the extention because the users machine had PowerPoint installed and understood that the file "looked" like a . ppt. Don't understand why not .pps.

The problem, besides IE6, was that our web server (IIS) was not aware of either MIME types for .pps or .ppt. So we had to add the correct MIME types so the server would not deliver them as "application/octet-stream". I understand that by using "application/octet-stream" IE6 will try to guess the MIME type.

So we added:

.pps = "application/vnd.ms-powerpoint"
.ppt = "application/vnd.ms-powerpoint"

Now it works fine with IE6.

I hope this helps solve your problem.


use this header flag: Content-Disposition: attachment; filename="yourfilename.extension"


This is a known problem, and the only solution is to edit the client computer's registry, which I'm sure doesn't help you a lot.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜