It depends on how you have structured your application, on some applications where you have several places to access the image, the querying will ofcourse slow down compared to directly accessing the file from the file system. Then there’s another issue/overhead of writing additional code to extract the images and display in a meaningful way.
Storing paths and using them is what I prefer. But you can go with DB too
There is nothing like DB is the best or File system is the best - place to store images. It just depends on how you are designing the structure of your application.
This is the most stupid thing i ever heard for a while now, i would like to see you handling a database with 1000 big images(> 5 mb) and also i would like to see you manipulating the images (like resize or watermark), all of these in a website that gets >= 10000 hits/day.
Security ? How is more secure to save into database than using the file system ?
Aside from what’s already mentioned, going with the FS/URL enables better site performance with misc web server performance boost systems (caching, different web server for certain file types (.jpg etc)) and also supports CDN usage when/if applicable. Although, I must note that “premature optimization is the root of all evil”… .
I can only add that when you’re working on something that should be stateless (a web-application that can easily run among multiple webservers), than it could be easy to separate any variable data from the application directories and thus save it in the database. We choose to save images in Amazon’s S3, which also enables you to separate it from the web application itself.
I agree with the majority above. I always store images on the file system and store some sort of reference to them in the database. If you’re concerned about preventing unauthorised users from accessing your images, you can always store them in a protected directory and use an action to write their contents out when requested by authorised users.
Must be really funny to store a few thousand huge images in a database and replicate them on several nodes. I guess if you have enough load you don’t exceed the cpu or ram resources of the server, but simply its bandwidth