开发者

Paperclip photo upload fails in IE8

开发者 https://www.devze.com 2023-03-15 18:48 出处:网络
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\',

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 imag开发者_如何转开发e content type Invalid format !!!"

Any solution or clue is much appreciated.


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


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消