Download a file

I want to download a file previously uploaded in the database
Its like providing a link and when clicked the file is downloaded to
your file system
How?? can i do that, I have no idea about it
Please can anyone help me


You should use the send_file or send_data methods available from the

send_data method(if the file is stored as a BLOB in the db)
send_data, :type => image.content_type, :disposition =>

in this example (from the api docs) this implies you have an
activerecord model called Image, with the fields 'data' and

send_file method (if the file is in the file system (can be outside
rails/public root)
send_file '/path/to.jpeg', :type => 'image/jpeg', :disposition =>

Look them up here:


also check out attachment_fu plugin for all round file upload/download

thanks man i would look into it

I want to provide a link "Download Image" which when clicked the image
is downloaded to the desired file system
Please can u help ,
I used the send_data function in my program for displaying the image.