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.

Advertisements
This entry was posted in Ruby on Rails and tagged , . Bookmark the permalink.

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

  1. cialis achat says:

    Quels mots… super, la phrase magnifique

  2. Pingback: Paperclip: validates_attachment_content_type always fails in IE 6,7 and 8 for jpeg and png image

  3. satish says:

    Great work dude………….It’s working……… Thanks

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s