简体   繁体   English

使用remotipart gem和Paperclip在Ruby on Rails中上传图像

[英]Image upload in Ruby on Rails using remotipart gem and Paperclip

I am having a form submit in which the user can be able to choose multiple images( choosing one by one ) not multiple enabled in file field. 我正在提交一个表单,其中用户可以选择多个图像(一个一个地选择),而不是在文件字段中启用多个图像。

When the user chooses the image I will add an image tag for image preview and hidden file field for each of the images added. 当用户选择图像时,我将为图像预览添加一个图像标签,并为每个添加的图像添加一个隐藏文件字段。

When the validation fails in back end it just removes a file field. 当后端验证失败时,它只会删除一个文件字段。 This removes a file field for each time when validation error occurs(any field validation). 每次发生验证错误(任何字段验证)时,都会删除一个文件字段。 Anything better can be done for this? 有什么更好的办法吗?

Why don't you show preview before image file being uploaded, follow the link 为什么在上传图片文件之前不显示预览,请点击链接

note : will not work in IE8(fileReader is supported from IE10). 注意 :在IE8中将不起作用(IE10支持fileReader)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM