I wish to upload multiple files using Paperclip in Rails. I have created a page that uploads the multiple files selected at a time. Now I wish to select more files using same file field and upload the files that are selected before and currently selected.
Following in my file_field:
<div class="queue-empty">
<span class="btn btn-primary btn-file">
<span class="fileinput-new">Click to Browse</span>
<%= photo.file_field :image,multiple: true,id: "File-Upload"%>
</span>
</div>
How can I append files to this file field without losing previously selected files?
I've had the same problem, used Carrierwave, but I think it doesn't matter here as all was done on client side with jQuery. So, what I've done was creating an empty array:
pushed uploaded file to array on file input change:
And then, when you have array of FileList objects, you can form FormData object and pass it on submit, like that:
Here is fiddle: https://jsfiddle.net/rp4kup3o/