Taylor Strait schrieb:
Lots of requests but not many answers on this topic. Here is how you do it:
FORM: <table> <% for i in 1..6 %> <tr> <td class='Label'><label>Title</label></td> <td><input id="<%= "picture_#{i}_title" %>" name="<%= "picture[#{i}][title]" %>" size="30" type="text" /></td> </tr> <tr> <td class='Label'><label for="image_data">Image</label></td> <td><input id="<%= "picture_#{i}_image_data_temp" %>" name="<%= "picture[#{i}][image_data_temp]" %>" type="hidden" /> <input id="<%= "picture_#{i}_image_data" %>" name="<%= "picture[#{i}][image_data]" %>" size="30" type="file" /></td> </tr> <tr> <td><br /></td> </tr> <% end %> </table>
CONTROLLER: params[:picture].each { |attr, value| unless value[:image_data].blank? new_image = Image.new new_image.person_id = session[:person_id] new_image.title = value[:title] new_image.image = value[:image_data] new_image.save end }
MODEL: class Image < ActiveRecord::Base
file_column :image
end
Hi Taylor,
how do you handle and display the errormessages, e.g: the 1st and 3rd file don´t match filesize or filetype etc out of a total of 4 ??
Best regards matthi
ps: i have also multiple_file upload running, even my code is different, the error_message_stuff should/could be handled the same