0

i have a problem with using paperclip. when i resart my rails server i can once upload a image using paperclip(success), but when i try to upload another image i'm always getting the error message: "Photo has an extension that does not match its contents". for file validation i use:

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

i use ruby 2.0 and rails 4.1.1 and the file i try to upload is ofc an image. can someone tell me how to fix this issue?

thanks, felix.

fel1xw
  • 576
  • 4
  • 7
  • Does commenting out the validation make the problem go away? What is the file type and extension of the 2nd image? – Chris Peters Jun 17 '14 at 17:52
  • its the same image, that's why i can't figure out where the problem is. and it's a simple .jpg-file – fel1xw Jun 17 '14 at 17:58
  • How about my first question? Does commenting out the call to `validates_attachment_content_type` make the error go away? I only ask to help you narrow it down to that line. – Chris Peters Jun 17 '14 at 18:34
  • no, when i uncomment this line an error occur, because paperclip needs that validation since version 4 i thought. – fel1xw Jun 17 '14 at 18:53
  • possible duplicate of [Validation failed: Upload file has an extension that does not match its contents](http://stackoverflow.com/questions/23629888/validation-failed-upload-file-has-an-extension-that-does-not-match-its-contents) – user1618143 Aug 11 '14 at 14:44

1 Answers1

0

Replace your code with this validates_attachment_content_type :asset, :content_type => /\Aimage\/.*\Z/

It should work

Mike McCallen
  • 307
  • 1
  • 14