Rails - input type=”file” multiple
I'm still on the hunt for an elegant multi-file upload for Rails.
I just 开发者_如何学Pythonlearned about the "input type=”file” multiple"
Does Rails support this? Any examples? tips on how to implement for uploading multiple photos to a photoalbum model in Rails?
Thanks
What you need is that more somenthing like this :
<%= f.file_field :attachment, :multiple => true %>
Here's a complete, working code snippet for Rails 5:
<%= form_for(@user, html: {multipart: true}) do |f| %>
<%= f.file_field :picture, accept: 'image/png,image/gif,image/jpeg,image/jpg', multiple: true %>
<%= f.submit 'Upload Picture' %>
<% end %>
This is easy in rails. If you're using form_for
, do it like so:
form_for(@user, :html => {:multipart => true}) do |f|
If you're doing this with form_tag
, it works like so:
form_tag new_user_path, :multipart => true
I hope this helps!
I have used http://www.fyneworks.com/jquery/multiple-file-upload/, and it looks good to me on jQuery-1.7.1 .
Hope it helps.
精彩评论