7

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.

safalmj
  • 692
  • 1
  • 5
  • 16

3 Answers3

12

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

thunder
  • 544
  • 5
  • 8
ashisrai_
  • 6,438
  • 2
  • 26
  • 42
2

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

thenengah
  • 42,557
  • 33
  • 113
  • 157
  • Hi Codeglot, as you suggested I did this : `validates_attachment_content_type :image, :content_type => ['/image/jpg','/image/jpeg', '/image/png', '/image/tiff', '/image/gif']`. But now the photo upload does not work in any browser. Did I missed anything? – safalmj Jun 27 '11 at 04:23
1

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.

Chris Barretto
  • 9,379
  • 3
  • 42
  • 45