When a user uploads an image to your site - what is your upload / storage strategy?
For example, lets say that users can upload:
- Avatars (profile images)
- Images in their forum posts
- Images in their articles
1. How would you organize the directory structure?
Would you just have three sub-directories in public/images (or maybe in public/uploads?):
- One for avatars:
public/images/avatars (or public/uploads/avatars or public/images/uploads/avatars?)
- One for forum posts:
public/images/forum
- One for articles:
public/images/articles
?
Or you would just have one public/uploads directory and put everything there, no matter if it's an avatar or uploaded image for forum post/article?
Or, for example, you would create username subfolders in the uploads directory... ?
2. Would you put all of the uploaded files (images) inside one directory? (for example, all uploaded avatars would be inside one directory)
If yes, then you could end up with thousands (or even hundreds of thousands) images (avatars) inside one directory and, as I understand it, this could be bad for many reasons.
If no, then what approach would you use? I know these two ways:
3. Finally, how would you name uploaded images (avatas, forum post images, article images...)?