Internet Explorer error validating file type, when uploading images using paperclip ( IE7, IE6 mine-type )

Back to Home Page...

12 March, 2009

Tag : Code : Ruby on Rails

I assume that everybody already knows about “Paperclip” and also the “validates_attachment_content_type” method to validate the file type against the mine-type sent by the browser.

The problem starts when your customer calls you saying that he/she is not able to upload his images, and an error “Image is not one of the allowed file types” pops every time he/she tries.

You consequently go straight to your model and check the current file type your “validates_attachment_content_type” allows, you try the application yourself, reload your tests and think the customer must be doing something wrong.

No, the only thing wrong with your customer is that he uses Internet Explorer and IE7 or IE6, ( Did not test IE5 ) will send a Jpeg mine-type as ‘pjpeg’ even if your Jpeg is not progressive, and the PNG mine type as ‘x-png’. ( GIF images will work fine )

Now you just need to change your model:

That should do it…

Be the first to comment on this article...