Is it appropriate to store the image files in the database? Or it would be better to store only the path of the file in the database, while keeping the file itself on the server?Are there any other methods for doing this right?
Store images in the database, or in files with a database link?
web development;php;database;mysql
I strongly advise you to store the images in the filesystem and not in the database.Storing images in the database has several disadvantages:The database might grow unexpectedly large. Sometimes space is an issue. Forexample with SQLServer express you have a 4GB limit.Data migrations can become a pain, for example if you switch fromSQLServer to OracleQueries can become very slow and you'll have a high database loadInteroperability with other applications is better if the images are on the filesystem and other applications use a different database. You can also access them directly and do not need database tools.Worse performance in generalYou'll probably have to create temporary files when retrieving the images from the database anyway. That's unnecessary.These disadvantages far outweigh the cost of keeping the paths to the images stored in the database synchronized with the filesystem. There're only few special cases in which it's better to store the images in the database.