I want to store small (50x50) images as avatar images, so one for each user. The user uploads the image and the PHP resizes/crops it to 50x50. I know how to store images as BLOB in database, and I know the other way is to store only the URL in DB and copy the image file to the server. I just wondering which one is the best practice? I think the number of users will vary in a range between about 1-200. So small images in small numbers, which storing method is the best for this?
4 Answers
I think,you can choose second way,to store image url in database and retrieve image from server,it will be easy for maintaining image and any other image re sizing operation

- 1,009
- 12
- 35
It's best practice to store the URL, storing images in your database can quickly lead to slow databases. If many users try at the same time to store images it will most likely break your database.

- 108
- 1
- 9
I would say it depends: Do they represent files or data in your application?
If never ever any file operations or anything like that are necessary for your image files i would consider them as data and store them as BLOB in the database. Benefits:
- No spreading of maybe thousands of files
- Use of database features like indexes if you want to retrieve the data
- Database-backup also backups your images on the fly
- No need of implementing file operation functions in your application

- 916
- 1
- 7
- 24
In that case you have to store url of images are uploading to server. This is efficient to retrieve, re-size and manipulation of images.It should be best practice.

- 71
- 8