Image Upload MIME type handling and IE

I was recently writing a script to handle image uploads from users to an Amazon S3 bucket and discovered one of those great IE quirks. Normally when writing an upload script you check for MIME type validity to make sure that the file that a user is uploading is uploading the correct type of file you are expecting to process. Now, I know that MIME types can be spoofed, but it’s still good to check against them to determine file type and prevent a user from accidentally uploading the wrong type of file. In writing the MIME type validation script though, I ran across a problem where versions of IE less than 9 would not detect my MIME type properly.

After doing a little research I found that older versions IE would return a different set of MIME types for JPEG and PNG image formats. Once I made accommodations for the other MIME types that IE passes to the server instead, things worked fine. When writing an image upload script and checking for valid MIME types, check for the following list:

  • image/jpeg
  • image/gif
  • image/png
  • image/x-png
  • image/x-citrix-png
  • image/x-citrix-jpeg
  • image/pjpeg

Related Articles:

Leave a Reply