Paperclip content type validation always fails on Internet Explorer

I just ran into a strange problem. It turns out that when you try to upload a file using paperclip on IE, the content-type is different from other browsers and you have to take of them if you want to use paperclip’s validates_attachment_content_type method.

I needed to add to my model validation the following content-types: “image/pjpeg” and “image/x-png”. I did not have a problem with gifs.

validates_attachment_content_type :logo, :content_type => ['image/jpeg', 'image/jpg', 'image/gif', 'image/png', 'image/pjpeg', 'image/x-png']

  • Pierre-Adrien B.

    Thanks for this. Another solution would be to use “:content_type => /^image/” in case you need to match any kind of image (even the weird IE ones), but would also accept gif or tiffs. Thanks a lot anyway.