Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Paperclip photo upload fails in IE8

I'm using paperclip to upload image in my app. The validation I've is :

 validates_attachment_content_type :image, :content_type => ['image/jpg','image/jpeg', 'image/png', 'image/tiff', 'image/gif']

Everything works well in firefox, chorme and IE9. But in IE8, I get an error - "Photos image content type Invalid format !!!"

Any solution or clue is much appreciated.

like image 632
safalmj Avatar asked Jun 27 '11 03:06

safalmj


3 Answers

says it needs extra image format image/pjpeg in content type i.e. :content_type => ['image/pjpeg']

Below will be helpful for sure.

http://blog.joshsoftware.com/2010/11/26/paperclip-validates_attachment_content_type-always-fails-in-ie-6-and-7-for-jepg-and-png-image/

http://blog.siyelo.com/tip-of-the-day-mime-types-for-paperclip-ie8

like image 136
ashisrai_ Avatar answered Nov 14 '22 03:11

ashisrai_


You can try this instead: content_type => /image/

like image 30
thenengah Avatar answered Nov 14 '22 03:11

thenengah


I think you may have misunderstood the previous answer. What he was suggesting was that you use a regular expression on containing the word 'image' instead of adding the forward slash in the front. So your modified code would look like this:

validates_attachment_content_type :image, :content_type => /image/

The // means you are using a regular expression for the content type instead of being explicit by each element in the array. The above would search the whole content_type string and match image, or you can be a little more strict and use:

validates_attachment_content_type :image, :content_type => /^image/

which means that the string has to begin with the word 'image', which it should. This should help you through IE as well.

like image 1
Chris Barretto Avatar answered Nov 14 '22 03:11

Chris Barretto