# Handling Multiple Uploads on One Page

**URL:** <https://www.ruby-forum.com/t/handling-multiple-uploads-on-one-page/90363>\
**Category:** Rails\
**Created:** [March 28, 2007, 4:55am UTC](https://www.ruby-forum.com/t/handling-multiple-uploads-on-one-page/90363 "2007-03-28T04:55:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![starnix17](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f19dbf/32.png) [@starnix17](https://www.ruby-forum.com/u/starnix17)\
**Post date:** [March 28, 2007, 4:55am UTC](https://www.ruby-forum.com/t/handling-multiple-uploads-on-one-page/90363/1 "2007-03-28T04:55:50Z")

</div>

I’ve been trying to create a page like this:  
[http://img175.imageshack.us/img175/7323/mephistohw0.png](http://img175.imageshack.us/img175/7323/mephistohw0.png)  
I was able to browse through the Mephisto source and figure out the  
JavaScript to add upload fields dynamically, but I cannot figure out  
how to process an unlimited amount of uploads in the controller.

In the Mephisto source it seems that each upload is stored in an  
array, however, I cannot recreate this in my application. Can anyone  
explain to me how to pull this off the DRY way?

---

<div class="post-metadata">

**Author:** ![starnix17](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f19dbf/32.png) [@starnix17](https://www.ruby-forum.com/u/starnix17)\
**Post date:** [March 28, 2007, 7:43pm UTC](https://www.ruby-forum.com/t/handling-multiple-uploads-on-one-page/90363/2 "2007-03-28T19:43:02Z")

</div>

Hi,

On Mar 27, 10:54 pm, “TeeC” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’ve been trying to create apagelike this:[http://img175.imageshack.us/img175/7323/mephistohw0.png](http://img175.imageshack.us/img175/7323/mephistohw0.png)  
> I was able to browse through the Mephisto source and figure out the  
> JavaScript to add upload fields dynamically, but I cannot figure out  
> how to process an unlimited amount ofuploadsin the controller.
> 
> In the Mephisto source it seems that each upload is stored in an  
> array, however, I cannot recreate this in my application. Can anyone  
> explain to me how to pull this off the DRY way?

You have to give your html tag a tag like ‘apples[]’.

\<%= form\_remote\_tag :update =\> @html\_division, :url =\> {:action=\>  
‘proceed’} %\>

\<%= file\_field\_tag “apples[]” %\>  
\<%= file\_field\_tag “apples[]” %\>  
\<%= file\_field\_tag “apples[]” %\>  
\<%= file\_field\_tag “apples[]” %\>  
\<%= file\_field\_tag “apples[]” %\>  
\<%= file\_field\_tag “apples[]” %\>

\<%= submit\_tag “Send apples” %\>  
\<%= end\_form\_tag %\>

This way, your controller will receive an array.

params[:apples].each do |an\_apple|  
do\_something\_with\_the\_apple an\_apple  
end

---

<div class="post-metadata">

**Author:** ![starnix17](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f19dbf/32.png) [@starnix17](https://www.ruby-forum.com/u/starnix17)\
**Post date:** [March 30, 2007, 8:31am UTC](https://www.ruby-forum.com/t/handling-multiple-uploads-on-one-page/90363/3 "2007-03-30T08:31:52Z")

</div>

yeah, i had this exact problem. so i wrote a tutorial after going  
through mephisto line for line with a ruby book. share with me the  
javascript, please.

[http://rubyonrailsnotes.blogspot.com/2007/03/multiple-file-uploads-with-attachmentfu.html](http://rubyonrailsnotes.blogspot.com/2007/03/multiple-file-uploads-with-attachmentfu.html)

---

<div class="post-metadata">

**Author:** ![starnix17](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f19dbf/32.png) [@starnix17](https://www.ruby-forum.com/u/starnix17)\
**Post date:** [April 5, 2007, 6:16pm UTC](https://www.ruby-forum.com/t/handling-multiple-uploads-on-one-page/90363/4 "2007-04-05T18:16:10Z")

</div>

Thanks for the help everyone, I was able to use Sébastien’s to handle  
the uploads, and Plewizard’s tutorial helped on processing it.

Thanks again!  
Tony
