# Multiple file upload

**URL:** <https://www.ruby-forum.com/t/multiple-file-upload/151521>\
**Category:** Rails\
**Created:** [October 22, 2008, 11:53am UTC](https://www.ruby-forum.com/t/multiple-file-upload/151521 "2008-10-22T11:53:16Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![subhadip](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3d9bf3/32.png) [@subhadip](https://www.ruby-forum.com/u/subhadip)\
**Post date:** [October 22, 2008, 11:53am UTC](https://www.ruby-forum.com/t/multiple-file-upload/151521/1 "2008-10-22T11:53:16Z")

</div>

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

Files (maximum 3):
  
  

\<%= f.submit:Create %\>

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

---

<div class="post-metadata">

**Author:** ![subhadip](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3d9bf3/32.png) [@subhadip](https://www.ruby-forum.com/u/subhadip)\
**Post date:** [October 22, 2008, 12:31pm UTC](https://www.ruby-forum.com/t/multiple-file-upload/151521/2 "2008-10-22T12:31:05Z")

</div>

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](http://praps.com) ??

Regards,  
Ratnavel.

---

<div class="post-metadata">

**Author:** ![subhadip](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3d9bf3/32.png) [@subhadip](https://www.ruby-forum.com/u/subhadip)\
**Post date:** [October 22, 2008, 1:54pm UTC](https://www.ruby-forum.com/t/multiple-file-upload/151521/3 "2008-10-22T13:54:21Z")

</div>

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](http://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.

---

<div class="post-metadata">

**Author:** ![subhadip](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3d9bf3/32.png) [@subhadip](https://www.ruby-forum.com/u/subhadip)\
**Post date:** [October 22, 2008, 1:34pm UTC](https://www.ruby-forum.com/t/multiple-file-upload/151521/4 "2008-10-22T13:34:05Z")

</div>

Have you looked at swfupload? Choose as many files as you want from a  
local folder and go…

---

<div class="post-metadata">

**Author:** ![subhadip](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3d9bf3/32.png) [@subhadip](https://www.ruby-forum.com/u/subhadip)\
**Post date:** [November 21, 2008, 11:51am UTC](https://www.ruby-forum.com/t/multiple-file-upload/151521/5 "2008-11-21T11:51:49Z")

</div>

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-

---

<div class="post-metadata">

**Author:** ![subhadip](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3d9bf3/32.png) [@subhadip](https://www.ruby-forum.com/u/subhadip)\
**Post date:** [November 21, 2008, 3:06pm UTC](https://www.ruby-forum.com/t/multiple-file-upload/151521/6 "2008-11-21T15:06:51Z")

</div>

Have you tried paperclip from thoughtbot?  
[http://www.thoughtbot.com/projects/paperclip/](http://www.thoughtbot.com/projects/paperclip/)
