Should I Save Images to Database or File System

It's been an issue for some time for developers the question of whether to save images on database or on file system. I decided to write this article to explain the pros and cons of both sides. Saving Images To File System Saving images to file system seems to be the best approach for some reasons. Images stored on file systems are easy to manage. When you need to retrieve the images, you just retrieve the path from your database and then load the image from there. They can also be easily previewed and this method separates your database information from image data. The down side of using file system to store images are the following: * File system images can easily be renamed or deleted. * File system images are susceptible to virus corruption (especially if you are running Windows) * If your application is a web application, additional security measures must be done to secure images from unauthorized copying, linking etc... Saving Images To Database Images stored on database tables is applicable for images where database size is not a major concern, usually for applications which is expected to have just a minimum amount of information and would not require large concurrent connections. This gives you a centralized storage for all your applications resources. But for application which requires large amount of information, the database approach must be avoided for the following reasons: * Saving images to tables bloats your database reducing performance * Storing and retrieving images to tables requires additional programming techniques for converting images to byte array data and vice-versa. * Images on database cannot be easily previewed. * Dump files for your SQL Tables would consume large disk space. * When databases are not well-structured and not maintained properly, bulky images can cause table/database corruption. It is up to you whether to use the file system or the database approach. To me, I usually prefer the file system approach.
Submitted byadminon Sun, 12/13/2009 - 18:06

Yes you are right. This is always what I am saying to those who choose to ask this kind of question. Thanks for this article. By the way I will create a program on how to save and retrieve images to database. You can use this program if you have few images to store in your database. But do not use this if you have a lot of images as what arjay have said.
Submitted byAnonymous (not verified)on Sat, 01/09/2010 - 16:06

nice post dear
Submitted byAnonymous (not verified)on Wed, 03/24/2010 - 17:02

If the application is big, and the size of images keep increasing daily, will you still using filesystem? What do you think, flick, myspace or facebook using? Filesystem or database to store the images?
Submitted byAnonymous (not verified)on Mon, 08/08/2011 - 18:51

just take data type of ms access database OLE object , in sql server there is option of image field
Submitted bygorio (not verified)on Mon, 07/09/2012 - 15:19

database is an organized collection of data, today typically in digital form. The data are typically organized to model relevant aspects of reality (for example, the availability of rooms in hotels), in a way that supports processes requiring this information (for example, finding a hotel with vacancies). See more at this site for further reading www.skilch.com gorio www.skilch.com
Submitted byAnonymous (not verified)on Sun, 12/02/2012 - 15:22

thanks for this article its great but please how I can use file system? Explain
Submitted bysba stuffon Tue, 12/23/2014 - 17:45

yes. you cant. you cant store the binary of an image in DB. But it consumes more space. Another Better Approach is to Store Paths Of Image In SQL and Then Retrieve the path and according to the path , image is stored.
Submitted bywedz anni (not verified)on Mon, 01/12/2015 - 06:43

can you please post that program? i really need a program like viewing student information with showing the images. . .
Submitted bysba stuffon Sat, 06/06/2015 - 16:50

In reply to by wedz anni (not verified)

I will post Car Selling site in ASP.Net. I use the same technique and you will learn fast

Add new comment