Non-standard image/pjpeg mimetype on IE

Here’s a lovely little Internet Explorer “feature” that may have web developers cursing, so I figured I would write a brief post about it in the hope that IE doesn’t waste an hour of your life like it did mine.

If you develop in PHP and need to add image upload functionality to a project, you will hopefully check the mimetype of each uploaded file to reduce the chance that it is a virus-laden script file or something equally nasty.

It’s quite easy to do by querying the “type” property of the uploaded file object. This page from the online PHP documentation has the details.

When checking an image upload, I normally check that the uploaded file’s mimetype is either image/jpeg, image/png or image/gif. These are standard mimetypes and everything works as it should, with users of the site uploading images to their hearts’ content.

Well, it works as it should until someone using Internet Explorer tries to upload a progressive JPEG image (a progressive JPEG is simply one that appears gradually more detailed when loaded, instead of loading from the top edge down). Every browser in the world treats such files as normal image/jpeg files, as they should. Except Internet Explorer of course, which uses the completely made-up mimetype of image/pjpeg.

Yes, that’s right, Microsoft invented their OWN mimetype for this solitary JPEG sub-type, presumably for no other reason than to annoy web developers the world over.

Add this to the list of mimetypes you check, and of course everything works fine. But you shouldn’t have to.

All I can say is, way to go Microsoft. Just when I thought you couldn’t surprise and disappoint me any more, you’ve succeeded in doing it again.

Hi Tony, yes it’s about accepting and processing uploads from browser forms. They all send image/jpeg except IE. As for IE6, it’s quite happy dealing with PNG files, it just won’t do alpha transparency properly. So I say to IE6 users: tough, upgrade.

Internet explorer will pretty much be an after thought after all these countries coming out and telling people not to use IE due to its security flaws. The impact will be massive. Whens the new ie going to come out i wonder?

I was wondering about this, it’s not exactly the first time MS have just ignored standards but it’s started to get boring now. With all the security issues my workplace are looking at deploying firefox site wide and avoiding the security hell that IE introduces.

As to one of the other commenters: I don’t feel sorry for Microsoft! Why feel sorry for such a huge corporation who makes so much money hand over fist. I mean, I could feel sorry for them if they were doing their very best and still the underdog, but they are in no way the underdog!

Back when Internet Explorer was first created it was top of the line, but the truth is all that has changed. There’s so many better browsers available, especially Mozilla Firefox of course.

Even browsers like Flock & Google Chrome seem to have more options, are easier to use, are more secure & just overall a much better browser than IE. Looks like microsoft better come up with something quick or their browser’s going to be run out of the market.

Hi Tony, yes it’s about accepting and processing uploads from browser forms. They all send image/jpeg except IE. As for IE6, it’s quite happy dealing with PNG files, it just won’t do alpha transparency properly. So I say to IE6 users: tough, upgrade.

I’m a webdesigner and one of the most frustrating things is to do different versions of css for IE7, IE8, IE9 (thank god IE6 is no longer in the picture). The above example is just another example of this horrific thing.

I have to agree with Lilly Bell on this. Although Internet Explorer may have run into a few problems over the last several years, MS have really started to get their act together recently, especially starting with v8.0 onwards. I think the overall user experience has improved significantly.

Finally we should remember that even Firefox is not without its own problems (the memory leak and other issues took them a fair amount of time to sort out.)

I had this issue today but quickly identified it when I dumped the $_FILES variable and saw pjpeg .. I knew I was only accepting jpeg and jpg.. I had never heard of pjpeg before as a mime type, so I searched google and found this..

IE is still doing this in 2013 with IE9 and IE10 .. fortunately it was a simple fix.. but it was confusing being on the line with a client and him trying and failing to upload while I was succeeding with the same exact file.