where did my uploaded file go?

Hi, i have made a file uploading function on my application, the thing
is

i want to allow my users to download the file (can be pdf, doc, img,
etc)

so in my file upload controller:

def download
     @photo = Photo.find(params[:id])
     send_file("#{RAILS_ROOT}/public/"+@photo.filename,
      :filename => @photo.filename,
      :type => @photo.content_type,
      :disposition => 'attachment')
end

this works perfectly fine, BUT only if the file actually exists in
../public/..

i noticed that when i try to upload a file using the app,

it doesn't automatically store it into the public folder.
if i manually copy paste the file into the public folder, the download
works fine.

this is my controller, (notice that the new & create methods doesn't say
anything about storing the uploaded files into the public folder)

class PhotoAdminController < ApplicationController
  def index
    list
    render :action => 'list'
  end

  # GETs should be safe (see
http://www.w3.org/2001/tag/doc/whenToUseGet.html)
  verify :method => :post, :only => [ :destroy, :create, :update ],
         :redirect_to => { :action => :list }

  def list
    @photo_pages, @photos = paginate :photos, :per_page => 10
  end

  def show
    @photo = Photo.find(params[:id])
  end

  def new
    @photo = Photo.new
  end

  def create
    @photo = Photo.new(params[:photo])
    if @photo.save
      flash[:notice] = 'Photo was successfully created.'
      redirect_to :action => 'list'
    else
      render :action => 'new'
    end
  end

  def edit
    @photo = Photo.find(params[:id])
  end

  def update
    @photo = Photo.find(params[:id])
    if @photo.update_attributes(params[:photo])
      flash[:notice] = 'Photo was successfully updated.'
      redirect_to :action => 'show', :id => @photo
    else
      render :action => 'edit'
    end
  end

  def destroy
    Photo.find(params[:id]).destroy
    redirect_to :action => 'list'
  end

  def download
     @photo = Photo.find(params[:id])
     send_file("#{RAILS_ROOT}/public/images/"+@photo.filename,
      :filename => @photo.filename,
      :type => @photo.content_type,
      :disposition => 'attachment')
   end
end

can someone teach me how to code my app to store the uploaded file into
the public folder?

thank you very much in advance!

I suggest you use the attachment_fu plugin. It works very well and
will give you the option of storing your files in the database, file
system or using Amazon S3. You could certainly write similar code
yourself, but why re-invent the wheel?

Aaron Chase wrote:

Read the section called 'attachment_fu migrations' in this document:
http://svn.techno-weenie.net/projects/plugins/attachment_fu/README.
DB storage is the default, although you probably want to store images
in the file system instread.

Aaron Chase wrote: