Should I store my images in the database or folders? [duplicate]
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
I'd go for folders. More flexibility if you run out of sttorage space (just move them to another disk and re-point), more flexibility with other apps (eg. Silverlight). I'd only use DB for files that had to be secure.
For any normal site you absolutely want this as part of the site app itself, not stored in a DB. A web site should as much as possible be self contained to keep it portable, and not adding round trips to the DB (even where caching) can only be a good thing. Web servers are very good at serving image files.
However, I personally am working on an app where the images are dynamically created and made available to the site through a second management application. Clearly these must be DB backed in some form to keep the images maintainable and secure.
Long story short, where the images have business value (i.e. they're content, they need security, or they're dynamic) you're going to have to store them in a DB. Where they're static and trivial let the website be a website.