Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I store my images in the database or folders? [duplicate]

Tags:

Possible Duplicate:
Storing Images in DB - Yea or Nay?

Hi

At the moment each Company on my website have 1 picture they can add to their profile. I save that image into the database....its their Company Logo.

Now i want to allow them to add more pictures. Now i don’t know if i must save it all in the database or save it in folders????

Reason why i think folders will be better is because there are so much nice articles with fancy silver light kinda features that i can use but all of them only cater for images saved in folders.

And since i am not THAT good its hard for me to change the code to look at the database instead of the examples that uses folders for image retrieval.

I would like to add something like this to my website (browsing through the images). Any code examples for me on how to do this when images are saved in the database? I am using ASP.NET with VB.net. Click here to view what i am talking about

Any ideas guys?

Regards Etienne

like image 436
Etienne Avatar asked Apr 03 '09 09:04

Etienne


People also ask

Is it better to store images in database or filesystem?

Generally databases are best for data and the file system is best for files. It depends what you're planning to do with the image though. If you're storing images for a web page then it's best to store them as a file on the server. The web server will very quickly find an image file and send it to a visitor.

Is it good to store images in database?

Storing images in a database table is not recommended. There are too many disadvantages to this approach. Storing the image data in the table requires the database server to process and traffic huge amounts of data that could be better spent on processing it is best suited to.

What is the best way to store image in database?

To insert images into a database, the database must support images. Images are stored in binary in a table cell. The data type for the cell is a binary large object (BLOB), which is a new SQL type in SQL3 for storing binary data.

What's the best way to store user uploaded images?

Store the images as a file in the file system and create a record in a table with the exact path to that image. Or, store the image itself in a table using an "image" or "binary data" data type of the database server.


1 Answers

I've done it both ways recently and personally; I do prefer using the directory method for storing the images while keeping their properties in a DB.

Main reason: I had client to whom I made a website for. On the Webiste; there was a Photo Gallery section that allowed the user to upload new photos (which could be browsed from the public site). Since my client hasn´t thought on optimizing the images before uploading; the *.jpg was over 1mb. I did implement the ability to update the image (once it was saved to the DB) but it had to be done one record at a time.

If this happens while storing the images in a directory, then the files can be saved locally, optimized and put back onto the server.

Here is an example

like image 114
Gthompson83 Avatar answered Jan 11 '23 01:01

Gthompson83