2013-08-22 53 views
0

我已经在使用carrierwavefogamazon S3我的应用程序中实现单张图像上传。 该解决方案直接将单张图像上传至amazon S3Multiupload - Carriervawe,Rails的,亚马逊S3

现在,问题是,如何扩展它与multiupload

我知道这个宝石S3 multipart,但更喜欢简单和可靠的解决方案,在这里我就不需要重构我现有的代码...

你能请占有率工作什么解决方案,你是最好的吗?

<div id="post"> 
    <label><%= t('dashboards.index.new_post') %></label> 
    <div> 
    <%= form_for(@post, :html => { :multipart => true }) do |f| %> 
    <%= f.text_area :text, :rows => '3', :placeholder => t('dashboards.index.new_post_placeholder'), :class => "post-text" %><br/> 


    <%= f.label  :image %> 
    <%= f.file_field :image %> <br/> 
     # place for multiple uploads 



    <%= f.label :tag_tokens, 'Tags' %> 
    <%= f.text_field :tag_tokens %> <br/> 

    <%= f.submit t('dashboards.index.send_message'), class: 'btn btn-success' %> 
    </div> 
<% end %> 

</div> 

回答

0

多个图像的选择需要添加

:html => { :multipart => true} 

在你的形式,

<%= form_tag(add_multiple_profile_image_path(:id=>@profile.id), :html => { :multipart => true}, :id => "profile_image_form") do %> 

也在你的形象标签即file_tag需要作为附加::文件,multiple:true AS,

<%= file_field_tag :profile_image, as: :file, multiple: true, :id=>"profile_image", name: 'profile_image' %> 

就是这样。现在选择多个文件并上传多个图像。