Last post May 13, 2010 09:20 AM by atconway
May 13, 2010 08:01 AM|klorder|LINK
I want to know which is the best place to store an image i.e
I should store image in a folder and store its link in database or store image directly into database
(I am developing a database of people so each record can have only one picture)
May 13, 2010 08:34 AM|amanbhullar|LINK
In my openion you shold store image on disk and save path in database.
If you save image in DB, then there is a overhead of converting image from db to disk.
Also, this will increase your database size
May 13, 2010 08:35 AM|DarrellNorton|LINK
See the discussions here:
May 13, 2010 08:36 AM|DarrellNorton|LINK
One of the links I posted references the SQL Server FILESTREAM. Using it is a great alternative that combines the best features of storing it in the database and storing it on the file system.
May 13, 2010 08:37 AM|jgangwisch|LINK
It depends on your customer base. Here are two examples where i did each scenario:
1. We needed pictures of employees so I stored them in the database as an image because they were only 100 X 100 images and we only had 35 employees
2. We needed customization logos from customers for products they ordered (We receive over 10000 orders a day); so i created an image folder to store the uploaded images.
Although if you are doing shared hosting i recommend saving the files to an external folder and not in the database. I know that providers charge more for sql server space these days.
May 13, 2010 09:20 AM|atconway|LINK
The main reason I would recommend storing files as a BLOB in SQL is when the images or files contain sensitive data (i.e. Medical Images, etc.) where you need the security that SQL Server provides. Otherwise storing and reading the file from a File System
is much faster; you can keep a reference to the file's location in SQL Server for the best method. Read this as well:
"performance wise, including an <IMG SRC> tag generated by the database and pointing to a file that already exists is going to be faster than pulling the file out of the database, generating a temp file on the web server, and streaming that to the user.
Also, table scans take more resources when there is an image datatype as opposed to a varchar that simply holds a 'pointer' to the file's location."
Another nice convenience of having them on a File System is that you can place a web site on top of the directory and access them via http:// instead of by server path that you have stored in the database.
Should I store images in the database or the filesystem?
Hope this helps!