【发布时间】:2014-05-24 13:14:26
【问题描述】:
我正在尝试使用 Carrierwave 和 Dropzone.js 上传多张图片,但是当我提交表单时出现以下错误。
请注意,没有 dropzone.js 的相同表单可以正常工作,这意味着当我只是使用 HTML5 上传多个图像时。
请查看下面我提交表单时创建的哈希(通过 ajax 使用 dropzone)
"project_images_attributes"=>[{"image"=
[#, @original_filename="artist4.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"project[project_ images_attributes][][image][]\"; filename=\"artist4.jpg\"\r\nContent-Type: image/jpeg\r\n">, #, @original_filename="feed1.jpg", @骗局 tent_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"project[project_images_attributes][][image][]\"; filename=\"feed1.jpg\"\ r\nContent-Type: image/jpeg\r\n">, #, @original_filename="gallery1.jpg", @content_type="image/jpeg", @headers="Content-Disposition: 表格数据; name=\"项目[project_images_attributes][][image][]\"; filename=\"gallery1.jpg\"\r\nContent-Type: image/jpeg\r\n">]}]}, "project-vide o"=>[""], "commit"=>"创建项目"}
不允许的参数:图片
请注意,我已将控制器中的图像参数列入白名单,并且它使用 HTML 5 工作,但不使用 ajax 和 dropzone.js
有谁知道如何解决这个问题?
谢谢
【问题讨论】:
-
从您已将属性列入白名单的控制器共享相关代码。
标签: ruby-on-rails-4 carrierwave strong-parameters dropzone.js