# Storing images: filesystem or database?

**URL:** <https://www.ruby-forum.com/t/storing-images-filesystem-or-database/58641>\
**Category:** Rails\
**Created:** [April 24, 2006, 12:24pm UTC](https://www.ruby-forum.com/t/storing-images-filesystem-or-database/58641 "2006-04-24T12:24:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![stepheneb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/71e660/32.png) [@stepheneb](https://www.ruby-forum.com/u/stepheneb)\
**Post date:** [April 24, 2006, 12:24pm UTC](https://www.ruby-forum.com/t/storing-images-filesystem-or-database/58641/1 "2006-04-24T12:24:03Z")

</div>

For a while i’ve been storing image in my PHP apps in the filesystem,  
but with the potential for a Rails project coming up i thought it was  
time for a review :0)

In everyone’s experience, is it best to store uploaded images in the db  
or just stick them on the filesystem with a reference in the db?

I’ve seen various performance tests and security arguments for and  
against each method so it’s difficult to know what’s best.

Does anyone know which method Flickr use? I’m assuming whatever they’re  
doing would be a good place to start :0)

Cheers,

Steve

---

<div class="post-metadata">

**Author:** ![stepheneb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/71e660/32.png) [@stepheneb](https://www.ruby-forum.com/u/stepheneb)\
**Post date:** [April 24, 2006, 12:30pm UTC](https://www.ruby-forum.com/t/storing-images-filesystem-or-database/58641/2 "2006-04-24T12:30:10Z")

</div>

Check the message archives for the pros vs. cons on this using Rails -  
it comes up for discussion here every few weeks, and you might find  
that everything has already been said that you’ll be interested in.

Regards

Dave M.

---

<div class="post-metadata">

**Author:** ![stepheneb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/71e660/32.png) [@stepheneb](https://www.ruby-forum.com/u/stepheneb)\
**Post date:** [April 24, 2006, 12:33pm UTC](https://www.ruby-forum.com/t/storing-images-filesystem-or-database/58641/3 "2006-04-24T12:33:18Z")

</div>

Probably should have done that before posting :0)

Cheers,

Steve

---

<div class="post-metadata">

**Author:** ![stepheneb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/71e660/32.png) [@stepheneb](https://www.ruby-forum.com/u/stepheneb)\
**Post date:** [April 24, 2006, 3:02pm UTC](https://www.ruby-forum.com/t/storing-images-filesystem-or-database/58641/4 "2006-04-24T15:02:23Z")

</div>

I think…its always better to store images in file system…if the  
images  
can be large and can have several versions…

last argument is…because suppose you use RMagick to modify the image  
and  
store it under some other name/dir… for all these cases file system  
is  
better…
