AnApprentice
AnApprentice

Reputation: 111040

Rails - input type=”file” multiple

I'm still on the hunt for an elegant multi-file upload for Rails.

I just learned 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

Upvotes: 5

Views: 10045

Answers (4)

Fellow Stranger
Fellow Stranger

Reputation: 34093

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 %>           

Upvotes: 3

Swati Sucharita
Swati Sucharita

Reputation: 64

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.

Upvotes: 0

Davidslv
Davidslv

Reputation: 654

What you need is that more somenthing like this :

<%= f.file_field :attachment, :multiple => true %>

Upvotes: 3

Jaime Bellmyer
Jaime Bellmyer

Reputation: 23317

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!

Upvotes: 1

Related Questions