Forum Moderators: phranque

Message Too Old, No Replies

Mime Types, Excel Files, and IE

         

mayest

9:28 pm on Jan 25, 2009 (gmt 0)

10+ Year Member



This is driving me crazy. I wrote an Excel 2003 add-in and posted it to my blog. I then tried downloading it using Firefox and got a page of gibberish instead of a download prompt. I figured that it was a problem with Mime types, so I searched and found that I should have this line in .htaccess:

AddType application/vnd.ms-excel .xla

That solved it in Firefox. However, IE insists on trying to change the file extension. It has to be .xlA, but IE wants to rename the file so that it has a .xlS format. The .xlS is a regular workbook, while .xlA is an add-in.

Is there anything I can do to stop IE from renaming the file? I'm using 7, but I've seen the same behavior in IE 6 on another site that I run.

jdMorgan

10:03 pm on Jan 25, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Use a hex editor to open a downloaded .xia file locally. Look at the first eight bytes, and compare them to those in a downloaded .xls file -- If they are the same, then this may be a "Microsoft problem" in that the .xia file is being saved with the "xls" marker tag in it, instead of "xia."

One characteristic of IE that Webmasters need to always bear in mind is that MS chose to make IE ignore the Content-Type response header sent by servers. Instead, in an effort to 'dumb things down' and compensate for Webmaster errors in configuring their servers' Content-Type headers to reflect the correct MIME-type, IE analyzes the actual content and takes a best-guess at what kind of file it is. So, this leads to problems when they get it wrong -- or don't properly support even their own formats.

All other browsers (that I know of) properly use the MIME-type indicated in the server Content-Type response header.

Jim

Caterham

5:12 pm on Jan 26, 2009 (gmt 0)

10+ Year Member



Firefox ignores the Content-Type response header if you serve a feed (i.e. XML file) with
Content-Type text/plain
. Firefox continues with the feed option chosen in the preferences instead of displaying the xml file as plain text. I was quite surprised when I trapped into this behavior...

M$ offers a "fix" to prevent MIME-sniffing for IE 8 with a response header

X-Content-Type-Options nosniff
.

mayest

5:38 pm on Jan 26, 2009 (gmt 0)

10+ Year Member



Jim, thanks for that. I suspect that you are right about IE trying to guess at the content type. I'll have a look at the files in a hex editor. I'll also add a note telling IE users that they will have to rename the file.

g1smd

8:52 pm on Jan 26, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I hate the fact that IE ignores the MIME type and instead guesses from the content what it thinks is coming down the line.