我正在使用回形针在我的应用程序中上传图像。我的验证是:
validates_attachment_content_type :image, :content_type => ['image/jpg','image/jpeg', 'image/png', 'image/tiff', 'image/gif']
在 Firefox、chorme 和 IE9 中一切正常。但在IE8中,我得到一个错误 - “照片图像内容类型无效格式!!! ”
非常感谢任何解决方案或线索。
我正在使用回形针在我的应用程序中上传图像。我的验证是:
validates_attachment_content_type :image, :content_type => ['image/jpg','image/jpeg', 'image/png', 'image/tiff', 'image/gif']
在 Firefox、chorme 和 IE9 中一切正常。但在IE8中,我得到一个错误 - “照片图像内容类型无效格式!!! ”
非常感谢任何解决方案或线索。
说它需要image/pjpeg
内容类型中的额外图像格式,即:content_type => ['image/pjpeg']
下面肯定会有所帮助。
http://blog.siyelo.com/tip-of-the-day-mime-types-for-paperclip-ie8
你可以试试这个:content_type => /image/
我想你可能误解了前面的答案。他的建议是在包含“图像”一词时使用正则表达式,而不是在前面添加正斜杠。因此,您修改后的代码将如下所示:
validates_attachment_content_type :image, :content_type => /image/
// 表示您正在对内容类型使用正则表达式,而不是对数组中的每个元素都明确表示。以上将搜索整个 content_type 字符串并匹配图像,或者您可以更严格一些并使用:
validates_attachment_content_type :image, :content_type => /^image/
这意味着字符串必须以单词“image”开头,这是应该的。这也应该可以帮助您通过 IE。