# Multiple file uploads - only one file object gets posted

**URL:** <https://www.ruby-forum.com/t/multiple-file-uploads-only-one-file-object-gets-posted/56769>\
**Category:** Rails\
**Created:** [April 3, 2006, 7:01pm UTC](https://www.ruby-forum.com/t/multiple-file-uploads-only-one-file-object-gets-posted/56769 "2006-04-03T19:01:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [April 3, 2006, 7:01pm UTC](https://www.ruby-forum.com/t/multiple-file-uploads-only-one-file-object-gets-posted/56769/1 "2006-04-03T19:01:55Z")

</div>

All,

Trying to upload multiple files.

Form:

\<% index = 0  
for @image in images do %\>

 \<%= @image.path.split('/').last[0..39] %\>: \<% if ((! @image.path.nil?) && (@image.path.length \> 40)) %\> \<%= h("...") %\> \<% end %\> \<%= file\_field('image', 'fileobj', :index =\> index) %\> 

\<% index += 1  
end  
%\>

I browse for 3 of the many files, and submit the form:

When I look at params in the controller, I see:

“0”=\>{“fileobj”=\>#\<File:C:/DOCUME~1/WESLEY~1/LOCALS~1/Temp/CGI2444.0\>}

but the other two indices for which I expected File objects only show  
StringIO objects.

Why do I not see 3 files objects in my parameter array when I  
“Browse…” to three files and submit my form?

Thanks,  
Wes

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [April 10, 2006, 11:59pm UTC](https://www.ruby-forum.com/t/multiple-file-uploads-only-one-file-object-gets-posted/56769/2 "2006-04-10T23:59:13Z")

</div>

Hi,

this isn’t a real problem, which you are experiencing here.  
Due to this CGI stuff, a large “File” gets mapped in a File object,  
whereas  
small files are being represented by StringIO objects. The reason, why  
it is  
done in this way may be performance, but I’m not really sure about this.

To make the long story short, everything seems to be in order.

Markus

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [April 11, 2006, 6:06pm UTC](https://www.ruby-forum.com/t/multiple-file-uploads-only-one-file-object-gets-posted/56769/3 "2006-04-11T18:06:57Z")

</div>

I don’t have access to the original file name from a StringIO object  
though, correct?

So I will either have to capture the file name another way or just  
rename it myself?

Wes

Markus Piff wrote:

> Hi,
> 
> this isn’t a real problem, which you are experiencing here.  
> Due to this CGI stuff, a large “File” gets mapped in a File object,  
> whereas  
> small files are being represented by StringIO objects. The reason, why  
> it is  
> done in this way may be performance, but I’m not really sure about this.
> 
> To make the long story short, everything seems to be in order.
> 
> Markus

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [April 16, 2006, 10:28pm UTC](https://www.ruby-forum.com/t/multiple-file-uploads-only-one-file-object-gets-posted/56769/4 "2006-04-16T22:28:39Z")

</div>

Hi,

you do have access to the original filename, but the methods are  
different.  
For StringIO the method should be “original\_filename” whereas for File  
instances  
[http://www.nabble.com/forum/ViewPost.jtp?post=3729395&framed=y](http://www.nabble.com/forum/ViewPost.jtp?post=3729395&framed=y)  
the method is “path”.

So you see, you don’t have to rename anything.  
Sorry for the late answer, I was quite busy this week.

Markus

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [April 17, 2006, 12:22am UTC](https://www.ruby-forum.com/t/multiple-file-uploads-only-one-file-object-gets-posted/56769/5 "2006-04-17T00:22:39Z")

</div>

Markus,

I was unable to find an original\_filename method on the StringIO object.

Are you sure it’s there?

Wes  
Markus Piff wrote:

> Hi,
> 
> you do have access to the original filename, but the methods are  
> different.  
> For StringIO the method should be “original\_filename” whereas for File  
> instances  
> [http://www.nabble.com/forum/ViewPost.jtp?post=3729395&framed=y](http://www.nabble.com/forum/ViewPost.jtp?post=3729395&framed=y)  
> the method is “path”.
> 
> So you see, you don’t have to rename anything.  
> Sorry for the late answer, I was quite busy this week.
> 
> Markus
