# Multiple upload using attachement fu

**URL:** <https://www.ruby-forum.com/t/multiple-upload-using-attachement-fu/114404>\
**Category:** Rails\
**Created:** [September 12, 2007, 10:58am UTC](https://www.ruby-forum.com/t/multiple-upload-using-attachement-fu/114404 "2007-09-12T10:58:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rajgerman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e274bd/32.png) [@rajgerman](https://www.ruby-forum.com/u/rajgerman)\
**Post date:** [September 12, 2007, 10:58am UTC](https://www.ruby-forum.com/t/multiple-upload-using-attachement-fu/114404/1 "2007-09-12T10:58:28Z")

</div>

Hey,

I have managed to successfully implement image upload using the  
attachment\_fu plugin. I require to upload multiple images, possibly each  
with a different title and category. I have provided my code below. I  
have been working on this for ages and would really appreciate any  
suggestions.

\<–new.rhtml (form)–\>  
\<%= error\_messages\_for :logo %\>

\<% form\_for(:logo, :url =\> {:action =\> ‘create’},  
:html =\> { :multipart =\> true }) do -%\>

Upload A Logo: \<%= file\_field :logo, :uploaded\_data %\>

Title: \<%= text\_field :logo, :title %\>

Category: \<%= select :logo, :category\_id, Category::CATEGORY\_NAMES, :prompt =\> "Select a category" %\>

\<%= submit\_tag 'Create' %\>

\<% end -%\>

\<–upload\_controller.rb–\>  
class UploadController \< ApplicationController

def index  
@logo = Logo.find(:all, :conditions =\> {:parent\_id =\> nil}, :include  
=\> :category)  
end

def new  
@logo = Logo.new  
end

def create  
@logo = Logo.new(params[:logo])  
if @logo.save  
flash[:notice] = ‘Logo was successfully created.’  
redirect\_to :controller =\> ‘upload’, :action =\> ‘index’  
else  
render :action =\> :new  
end  
end

def show  
@logo = Logo.find(params[:id])  
end

def delete  
@logo = Logo.find(params[:id])  
if @logo.destroy  
flash[:notice] = ‘Deleted’  
redirect\_to :action =\> ‘index’  
end

end

end

\<–logo.rb (model)–\>  
class Logo \< ActiveRecord::Base

belongs\_to :category

has\_attachment :content\_type =\> :image,  
:storage =\> :file\_system,  
:max\_size =\> 500.kilobytes,  
:resize\_to =\> ‘320x200\>’,  
:thumbnails =\> { :thumb =\> ‘100x100\>’ }

validates\_as\_attachment

end

Regards
