【问题标题】:Paperclip does not allow jpg upload, even though it is sepcified in content type.Paperclip 不允许上传 jpg,即使它在内容类型中已被指定。
【发布时间】:2012-05-11 12:48:50
【问题描述】:

我正在使用回形针来接受图片上传。我的附件有以下验证:

validates_attachment :image, content_type: { content_type: ['image/jpg', 'image/png'] }, size: { in: 0..500.kilobytes }

上传 png 可以正常工作,但上传 jpeg 不起作用,并导致表单中显示保存错误。错误在 image_content_type 上。我该如何调试这个问题?

【问题讨论】:

    标签: ruby-on-rails ruby-on-rails-3 paperclip


    【解决方案1】:

    我相信要使用的correct MIME typeimage/jpeg

    validates_attachment :image, content_type: { content_type: ['image/jpeg', 'image/png'] }, size: { in: 0..500.kilobytes }
    

    【讨论】:

      猜你喜欢
      • 2019-06-28
      • 1970-01-01
      • 2012-07-01
      • 1970-01-01
      • 2021-04-19
      • 1970-01-01
      • 2018-04-04
      • 2011-11-14
      • 2012-03-05
      相关资源
      最近更新 更多