Paperclip: validates_attachment_content_type always fails in IE 6 and 7 for jepg and png image

If you are using paperclip plugin for uploading images in your rails application and you are validating image format.
Image format validation working in Firefox, safari but not in IE, even you are uploading image in correct format in IE then they showing error,  image format not correct.

eg:
validates_attachment_content_type :image, :message => ‘Please upload correct format’, :content_type => %w( image/jpeg mage/png image/gif )

This validation does not work in IE 6 and 7. Because IE treats files differently,  they added extra text on them (I’ve not clear on this point why they add). 

please refer this link http://groups.google.com/group/paperclip-plugin/browse_thread/thread/3e09d6943616ce7b

Solution For This problem:
you need to add following format in your validation

for jpeg image – image/pjepg and for png image image/x-png format add in your in validates_attachment_content_type

eg: validates_attachment_content_type :image, :message => ‘Please upload correct format’, :content_type => %w( image/jpeg image/png image/gif image/pjpeg image/x-png )

For ‘gif’ image no additional format require in IE.

3 thoughts on “Paperclip: validates_attachment_content_type always fails in IE 6 and 7 for jepg and png image

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.