upload multiple files with a single file_uploader rails 4 -
in sr_documents/form
:
<%= simple_form_for @service_request,:url=>upload_document_path(@service_request.id),:remote=>true,:html => { :multipart => true } |f| %> <%= f.nested_fields_for :sr_documents |q| %> <%= q.input :file,:required => true,:hint=>"(only .pdf,.docx,.doc,.txt)", multiple: true,:name=>'file[]' %> <%= f.button :submit ,:class=> "btn btn-go button",data: {"disable-with" => "processing..."}%> <%= f.add_nested_fields_link :sr_documents,"add new file" %> <%end%>
i using gem nested_form_fields
, paperclip
in app. through above code, able upload multiple files. concern how upload multiple files single file_uploader. used name file[]
, :multiple=>true
, still not working. please me out.
i needed same thing didn't fine solution. in project using
= file_field_tag :image_files, :multiple => true, name: 'image_files[]', style: 'display:none', :id => 'fileinput'
user have select multiple files after selecting field. , in controller able files params[:image_files]
i building images :
# method builds images per image_files params def build_images (params[:image_files] || []).each |img| @product.images.build(file: img) end end
Comments
Post a Comment