Should I Save Images to Database or File System

Submitted by: 

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.


can you please post that program? i really need a program like viewing student information with showing the images. . .

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


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.


Nice article.

thanks for this article its great but please how I can use file system? Explain

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


just take data type of ms access database OLE object , in sql server there is option of image field

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?

nice post dear

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.

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • You may insert videos with [video:URL]
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <th> <img> <h1> <h2> <h3> <iframe> [video]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.