Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails IE8中的回形针照片上载失败_Ruby On Rails_Internet Explorer 8_Paperclip Validation - Fatal编程技术网

Ruby on rails IE8中的回形针照片上载失败

Ruby on rails IE8中的回形针照片上载失败,ruby-on-rails,internet-explorer-8,paperclip-validation,Ruby On Rails,Internet Explorer 8,Paperclip Validation,我正在用回形针在我的应用程序中上传图像。我得到的验证是: validates_attachment_content_type :image, :content_type => ['image/jpg','image/jpeg', 'image/png', 'image/tiff', 'image/gif'] 在firefox、chorme和IE9中一切都运行良好。但是在IE8中,我得到一个错误- “照片图像内容类型格式无效!!!” 非常感谢任何解决方案或线索。您可以尝试以下方法:con

我正在用回形针在我的应用程序中上传图像。我得到的验证是:

 validates_attachment_content_type :image, :content_type => ['image/jpg','image/jpeg', 'image/png', 'image/tiff', 'image/gif']
在firefox、chorme和IE9中一切都运行良好。但是在IE8中,我得到一个错误- “照片图像内容类型格式无效!!!”


非常感谢任何解决方案或线索。

您可以尝试以下方法:
content\u type=>/image/
我想您可能误解了前面的答案。他建议在包含单词“image”时使用正则表达式,而不是在前面添加正斜杠。因此,修改后的代码如下所示:

validates_attachment_content_type :image, :content_type => /image/
//表示对内容类型使用正则表达式,而不是由数组中的每个元素显式表示。上面将搜索整个内容类型字符串并匹配图像,或者您可以更严格地使用:

validates_attachment_content_type :image, :content_type => /^image/

这意味着字符串必须以单词“image”开头,它应该这样做。这应该也能帮助你通过IE。

说它需要在内容类型中使用额外的图像格式
image/pjpeg
,即
:content\u type=>['image/pjpeg']

下面肯定会有帮助


Hi-Codeglot,正如你建议的那样,我这样做了:
验证了附件内容类型:image,:content\u type=>['/image/jpg'、'/image/jpeg'、'/image/png'、'/image/tiff'、'/image/gif']
。但是现在照片上传在任何浏览器中都不起作用。我错过什么了吗?谢谢你的提示。这里非常有用:)