Forum: Ruby on Rails multiple file upload

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Subhadip C. (Guest)
on 2008-10-22 13:53
Attachment: application.js (0 Bytes)
Hi,
  i am trying for uploading multiple files using attachment_fu plugin.
  i use MultiSelector javascript for this purpose.It helps me to store
  minimum three files before uploading.but when i deleted one file
  and replace with another file.the rest of the files including this
 files are not save in the database.

  i include required javascript files as attachment.
  here is my code,
 in view

  <% form_for :fileindex, :url => { :action => 'create' }, :html => {
:multipart => true } do |f| %>
        <%= javascript_include_tag "multifile_compressed"%>
    <%= file_field 'file', 'data' %><br>
    <div id="files_list">Files (maximum 3):</div>
    <script>
    var multi_selector = new MultiSelector( document.getElementById(
'files_list' ),3);
    multi_selector.addElement( document.getElementById( 'file_data' ) );
    </script>
    <p><%= f.submit:Create %></p>
    <% end %>

 in controller:
  def create
   i = 0
while params['file_'+i.to_s] !="" && !params['file_'+i.to_s].nil?
 # puts params['file'+i.to_s]
  p = Hash["fileindex"=>{"uploaded_data"=>""}]
 # puts p
  p["fileindex"]["uploaded_data"] = params["file_"+i.to_s]
 # puts p["Fileindex"].size
 # if p["Fileindex"].size>0
    @fileindex = Fileindex.create! p["fileindex"]
 # end
i += 1
end
end

 any urgent help is required.
                      thanks,
Ratnavel P. (Guest)
on 2008-10-22 14:31
May I know y u need 3 uploads at a time. I guess with attachment_fu u
cant upload and save multiplt files at one shot. Instead u need to
itrate and save.

if u could explain the requirement I may suggest an alternative
solution.

Anyway Is the requirement related to praps.com ??

Regards,
Ratnavel.
Andrew C. (Guest)
on 2008-10-22 15:34
Have you looked at swfupload?  Choose as many files as you want from a
local folder and go...
Subhadip C. (Guest)
on 2008-10-22 15:54
Ratnavel P S wrote:
> May I know y u need 3 uploads at a time. I guess with attachment_fu u
> cant upload and save multiplt files at one shot. Instead u need to
> itrate and save.
>
> if u could explain the requirement I may suggest an alternative
> solution.
>
> Anyway Is the requirement related to praps.com ??
>
> Regards,
> Ratnavel.

 thanks Ratnaval,
   i want to upload multiple files.in view page i attach
   may one ,two or three(maximum three)files without delete
   any files and upload those files.it works beautifully.
   all files are successfully saved in the database.
   but there exist a delete button.If i delete one
   attach files and replace it with another file and try to
   upload it,it not works.the changed file is not save in
   the database.
nani (Guest)
on 2008-11-21 12:51
(Received via mailing list)
hi Subhadip Chakraborty,

     iam trying to upload multiple files using attachment_fu
plugin ....i have followed by ur code but i did't get it... can u plz
explain it more briefly... its very urgent......

     thanks in advance,
regards,
chowdari

On Oct 22, 2:53 pm, Subhadip Chakraborty <rails-mailing-l...@andreas-
Iros (Guest)
on 2008-11-21 16:06
(Received via mailing list)
Have you tried paperclip from thoughtbot?
http://www.thoughtbot.com/projects/paperclip/
This topic is locked and can not be replied to.