# How to show images stored in the database

**URL:** <https://www.ruby-forum.com/t/how-to-show-images-stored-in-the-database/129006>\
**Category:** Rails\
**Created:** [February 13, 2008, 2:41pm UTC](https://www.ruby-forum.com/t/how-to-show-images-stored-in-the-database/129006 "2008-02-13T14:41:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![saurabhpurnaye](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ee59a6/32.png) [@saurabhpurnaye](https://www.ruby-forum.com/u/saurabhpurnaye)\
**Post date:** [February 13, 2008, 2:41pm UTC](https://www.ruby-forum.com/t/how-to-show-images-stored-in-the-database/129006/1 "2008-02-13T14: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…  
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 P.  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![saurabhpurnaye](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ee59a6/32.png) [@saurabhpurnaye](https://www.ruby-forum.com/u/saurabhpurnaye)\
**Post date:** [February 13, 2008, 3:05pm UTC](https://www.ruby-forum.com/t/how-to-show-images-stored-in-the-database/129006/2 "2008-02-13T15:05:14Z")

</div>

On 13 Feb 2008, at 13:41, Saurabh P. wrote:

> 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’)
