Store Images in DB or on Filesystem
good day all,
i am about to implement an image upload/display feature in my web app.
my options are store images in the database or store path to images in the database and store images on the file system.
considering that i am using JSC to do my development, which option would you experts out there suggest.
thank you
kroikie.
[365 byte] By [
kroikiea] at [2007-11-26 16:14:45]

# 3
I've done both with a few projects that i've done. The first time I tried to use images, I stored them in a blob in a mysql database. I went through a few weeks of pain trying to get everything to work right.
For the current project I am working on, I am using images stored in my "/resources/images" folder and a path to them in the database and it works so much better and easier. There is much less of a learning curve for this type of image handling i believe. As far as performance I'm not sure if one is faster than the other. The main thing you have to watch out for with this method is to not use a "file" protocol, but an "http" protocol to display pictures or they will only be seen on the localhost. However I believe that is true for both procedures.
# 5
Generally, if you plan to store the images on the file system you need to guarantee unique file names.
I looked at doing this but wound up putting them into the DB because:
I didn't want to have to change file names.
I figured that as i was going to have to store the file's name, mime type and a bunch of other stuff it'd be neater and easier to just put the whole lot in the db. Also made backing up my app simpler as everything is in the DB.
# 7
This is not so much a setting as it is a way of retrieving images.
Here is an example of using "file" protocol:
<img src="C:/directory/picture.gif">
This can only be viewed from your localhost machine that has the images and webapp.
Here is an example of using "http" protocol:
<img src="/ProjectName/resources/images/picture.gif">
This will allow any computer to view the images.