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

Online

You should use the send_file or send_data methods available from the controller

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

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

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 => 'attachment'

Look them up here: www.gotapi.com/rubyrails

Joe

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

thanks man i would look into it

hi, 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.