# How downloading image in rails

**URL:** <https://www.ruby-forum.com/t/how-downloading-image-in-rails/103531>\
**Category:** Rails\
**Created:** [May 7, 2007, 4:20pm UTC](https://www.ruby-forum.com/t/how-downloading-image-in-rails/103531 "2007-05-07T16:20:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![veeraa2003](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b487fb/32.png) [@veeraa2003](https://www.ruby-forum.com/u/veeraa2003)\
**Post date:** [May 7, 2007, 4:20pm UTC](https://www.ruby-forum.com/t/how-downloading-image-in-rails/103531/1 "2007-05-07T16:20:34Z")

</div>

Hi everybody,

I want to display a link for downloading image from database.

def image  
@image = Classified.find(params[:id])  
send\_data @image.picture, :filename =\> “photo.jpg”,  
:type =\> @image.content\_type, :disposition =\> “attachment”

end

\<%= image\_tag (url\_for({:action =\> ‘image’,  
:id =\> @classified.id})) -%\>

But its still display the image only not displaying the link to  
download.

I use both :disposition as “inline” and “attachment”. But I cant get the  
link to download the image file. How is it possible. Please advice me.

Regards,  
Veeraa

---

<div class="post-metadata">

**Author:** ![veeraa2003](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b487fb/32.png) [@veeraa2003](https://www.ruby-forum.com/u/veeraa2003)\
**Post date:** [May 7, 2007, 4:37pm UTC](https://www.ruby-forum.com/t/how-downloading-image-in-rails/103531/2 "2007-05-07T16:37:18Z")

</div>

Take a look at send\_data method. Use this method within a controller  
action to send the data for your image to the client browser. You  
will then connect your action to a regular hyperlink within your view  
in the normal way.

On May 7, 10:20 am, Veera S. \<rails-mailing-l…@andreas-

---

<div class="post-metadata">

**Author:** ![veeraa2003](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b487fb/32.png) [@veeraa2003](https://www.ruby-forum.com/u/veeraa2003)\
**Post date:** [May 8, 2007, 7:19am UTC](https://www.ruby-forum.com/t/how-downloading-image-in-rails/103531/3 "2007-05-08T07:19:20Z")

</div>

Robert W. wrote:

> Take a look at send\_data method. Use this method within a controller  
> action to send the data for your image to the client browser. You  
> will then connect your action to a regular hyperlink within your view  
> in the normal way.
> 
> On May 7, 10:20 am, Veera S. \<rails-mailing-l…@andreas-

HI Robert,

Thanks for your kind reply. Thanks a lot.

By veeraa…
