ZigPress

consultancy · solutions · research

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.

24 Comments

  1. Is this the case with IE 8 as well or only the older IE’s?

  2. It came to my attention via IE7 but is also the case in IE8.

  3. Is this when you are uploading files via IE?

    I found users in my system were uploading pjpeg files and had to modify my image manipulation code to recognise it. I didn’t realise it was related to the IE browser.

    Don’t forget to check for image/jpg as well.

    And png is not naturally supported by IE6 browsers. So if you want to support those oldies who seem to want to avoid upgrading for life, its best to avoid png.

    If a user uploads any other image file format I instantly convert it to jpeg.

  4. 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. :)

  5. […] This post was mentioned on Twitter by Andy Towler, Klaus. Klaus said: RT @ZigPress: Latest blog article – Non-standard image/pjpeg mimetype on Internet Explorer: http://bit.ly/7U2Nmq […]

  6. 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?

  7. Fortunately, the days of IE doing whatever the hell they want are coming to an end. With all the competition they’re going to have to get used to being standard.

  8. 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.

  9. I guess Microsoft just keeps digging a bigger and bigger whole for themselves. I am almost starting to feel sorry for them!

  10. So annoying! I just fell into this trap with IE8. Such a waste of time. /rage

  11. Great, just another annoyance. Billy Boy can do what he wants I guess! Hope someone overtakes him eventually.

  12. 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!

  13. A link from microsoft:
    http://msdn.microsoft.com/en-us/library/ms775147%28VS.85%29.aspx#_replace

  14. Internet Explorer 8 is very good because it is as stable as Opera. I hate the previous versions of IE like IE6 because it hangs frequently. ‘

  15. 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.

  16. Great Work… :)

  17. I have to agree with Daniel, Mozilla Firefox is much much superior for web developers, just take SEO Quake Toolbar for example. Functionality is much better with Firefox and much faster than IE.

  18. […] Non-standard image/pjpeg mimetype on IE – ZigPressHere'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 … […]

  19. I still can’t believe anyone in their right mind is using IE. I stopped coding for it 2 years ago. Just got tired of writing two versions of websites…

  20. 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.

  21. 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.

  22. 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.)

  23. thanks, this problem took 3 hours of my work.

  24. 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.

Add a Comment