# how to show images stored in the database

**URL:** <https://discuss.rubyonrails.org/t/how-to-show-images-stored-in-the-database/24852>\
**Category:** rubyonrails-talk\
**Created:** [February 13, 2008, 1:41pm UTC](https://discuss.rubyonrails.org/t/how-to-show-images-stored-in-the-database/24852 "2008-02-13T13:41:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![11175](https://avatars.discourse-cdn.com/v4/letter/1/8edcca/32.png) [@11175](https://discuss.rubyonrails.org/u/11175)\
**Post date:** [February 13, 2008, 1:41pm UTC](https://discuss.rubyonrails.org/t/how-to-show-images-stored-in-the-database/24852/1 "2008-02-13T13:41:38Z")

</div>

Actually i have came across a situation where i will have to store an image in the database and show the same image.. for this purpose i have used LONGBLOB field in mysql and stored the image.. &nbsp;&nbsp;I have to show this image to the user from db.. and i dont knwo how to show the image in this way.. I have got answer for this in php on [http://www.weberdev.com/get\_example-4062.html](http://www.weberdev.com/get_example-4062.html)(php code.) There is some function called Header in php but i dont know about rails... Pls help me out.. Thanks and regards Saurabh Purnaye saurabh.purnaye@gmail.com

---

<div class="post-metadata">

**Author:** ![Frederick\_Cheung](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/frederick_cheung/32/3901_2.png) [@Frederick\_Cheung](https://discuss.rubyonrails.org/u/Frederick_Cheung)\
**Post date:** [February 13, 2008, 2:04pm UTC](https://discuss.rubyonrails.org/t/how-to-show-images-stored-in-the-database/24852/2 "2008-02-13T14:04:46Z")

</div>

> Actually i have came across a situation where i will have to store an image in the database and show the same image.. for this purpose i  
> have used LONGBLOB field in mysql and stored the image.. I have to show this image to the user from db.. and i dont knwo how  
> to show the image in this way..

Use send\_data. It allows you to tell the browser what mime type the  
image is so that the browser knows what to do with it. something like this should do the trick

send\_data(some\_chunk\_of\_data, :disposition =\> 'inline', :type=\> 'image/ png', :filename =\> 'foo.png')
