This project is archived and is in readonly mode.

#1997 ✓duplicate

Fail to send multiple files

Reported by phlawski | February 17th, 2009 @ 02:32 PM

When i tried to upload few images to server on new Rails 2.3.0 RC i found that some of my params just disappears. Here is what i have in controller:

def new

@hotel =
(1..8).each { }


def create

p params # Just for testing purposes


And here is my simple form:

<% form_for @hotel, :html => {:multipart => true} do |f| %>

<% f.fields_for :hotel_images do |hi| %>
  <%= hi.file_field :image %>
  <br />
<% end %

<% end %>

Sending empty form results in such params[:hotel] hash:

{ "hotel_images_attributes"=>{


} }

When i put one file in "slot" one named hotel[hotel_images_attributes][new_1][image] my params[:hotel][hotel_images_attributes] hash looks like:

"hotel_images_attributes"=>{ "new_1"=>{"image"=>#<File:/tmp/RackMultipart.22893.7>}, "new_3"=>{"image"=>nil}, "new_4"=>{"image"=>nil}, "new_5"=>{"image"=>nil}, "new_6"=>{"image"=>nil}, "new_7"=>{"image"=>nil}, "new_8"=>{"image"=>nil}}

so, somewhere new_2 key with values disappears. What interesting - when i put two files, on "new_1" and "new_2", then after upload there is no "new_3" and "new_4" and so on.. So, multiple files upload is impossible, because only one file is sent at all. But - funny thing is that when i put files on "new_1", "new_3" and for example "new_5" - whole bulk of files is sent properly, but ofcourse in resulting params hash there is no keys named "new_2" and "new_4" - so if there had been files they wouldn't have been available after transfer.

I tested this on Rails 2.3.0 RC using mongrel and thin on both - firefox and opera.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>