【问题标题】:How to validate sizes of multiple image uploads in CarrierWave uploader如何在 CarrierWave 上传器中验证多个图像上传的大小
【发布时间】:2015-07-27 02:20:56
【问题描述】:

我的上传器设置为像这样上传多个图片:

class User < ActiveRecord::Base
  mount_uploaders :avatars, AvatarUploader
end

在视图文件中:

<%= form.file_field :files, multiple: true %>

问题是结果将在 image_urls 的 json 字符串中。

然后如何验证我上传的每张图片的大小?

例如,每个图像应小于 5 兆字节。

非常感谢!

编辑: 这是基于 CarrierWave(0.11.0) 的新功能,感谢 Gen.

【问题讨论】:

    标签: ruby-on-rails carrierwave


    【解决方案1】:

    How to: Validate attachment file size

    而且没有 mount_uploaders 之类的东西:

    Undefined method `mount_uploaders'

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-11-23
      • 2016-06-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-29
      • 1970-01-01
      相关资源
      最近更新 更多