Ben Nadel
On User Experience (UX) Design, JavaScript, ColdFusion, Node.js, Life, and Love.
I am the chief technical officer at InVision App, Inc - a prototyping and collaboration platform for designers, built by designers. I also rock out in JavaScript and ColdFusion 24x7.
Meanwhile on Twitter
Loading latest tweet...
Ben Nadel at NCDevCon 2011 (Raleigh, NC) with:

Internet Explorer Aborts Images With The Wrong Mime-Type

By Ben Nadel on
Tags: ColdFusion

This is a really quick post; but, it took me over an hour to debug the other day, so I thought I would share. I was in a situation where I had to serve up images. This seemed to work well in every browser except IE (Internet Explorer). Furthermore, IE seemed to serve up some images and not others. After slowly narrowing it down, I finally figured out that it was a mime-type issue.

When I stated to dig into the problem, IE was aborting some of the image requests. When I looked in the network activity, IE was showing me:

"(Aborted)"

The confusing thing was that if I copied the image URL and opened up in another browser window, IE would prompt me to save the image. Then, after saving it, Windows had no problem opening up the image. So, it wasn't a "corrupt" image issue - something else was going on.

The thing that finally cued me in was the fact that IE prompted me to save the image rather than simply showing it inline. This made me think it had something to do with the Content-Disposition or the Mime-Type. And, after reviewing the code that served up the image, I discovered that my JPG images were being served with the mime-type:

"image/jpg"

Unfortunately (my bad!) the official mime-type of JPG images is:

"image/jpeg"

Once I fixed this, IE started serving up the JPG images properly.



Reader Comments

What? You mean the browser didn't know what you meant? That's crazy talk! :P

It can be frustrating when that happens. Thank you for bringing this up. What gets me, though, is that I seem to recall IE uploading files with the image/jpg MIME type if the extension is "jpg". I might be mistaken, of course...

Reply to this Comment

@Paul,

Another one that gets us, which is not a programming error, but a user error - people will often upload PNG files with a mislabeled ".jpg" file extension. This is another case where Firefox and Chrome are like "what-evs, I'll show it anyway" and IE is like, "Oh my gosh, how do I cope with such a catastrophic failure!".

Reply to this Comment

Post A Comment

You — Get Out Of My Dreams, Get Into My Comments
Live in the Now
Oops!
Comment Etiquette: Please do not post spam. Please keep the comments on-topic. Please do not post unrelated questions or large chunks of code. And, above all, please be nice to each other - we're trying to have a good conversation here.