Forum: Ruby on Rails Many file fields w/same name don't show up as params array

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Bb4bdf2b184027bc38d4fb529770cde5?d=identicon&s=25 Wes Gamble (weyus)
on 2006-04-01 02:29


I have a page where I am allowing the user to specify multiple image
files that are related to one HTML document.

I'm trying to set up my file_field correctly but am having trouble.

I'm trying to post into an array of images that belongs to a document.

I've tried:

<%= file_field('document', 'image[]') %>
<%= file_field('document[]', 'image[]') %>

and when I do debug(params), I never see more than one image in the
"document" hash.

My expectation was that this I could get params to have a document
element that then had one value which would be a hash of image values.
What am I doing wrong here?


Here is my form:

<%= form_tag( { :action => 'upload_images' },
              { :multipart => 'true' } )%>

<% for image in images do %>
      <%= image.path.split('/').last[0..39] %>:
      <% if ((! image.path.nil?) && (image.path.length > 40)) %>
         <%= h("...") %>
      <% end %>
      <%= file_field('document', 'image') %>
<% end %>

  <%= submit_tag "Upload Images" %>

<%= end_form_tag %>

This topic is locked and can not be replied to.