Welcome Guest, Not a member yet? Register   Sign In
User files and images location ... best practices.

Just wondering what the community feels is the best way to handle user files, like profile images ... should they:
a) be put in separate directories, ex: /user_files/userId/image.jpg
b) or, just all dumped into the same directory, ex: /user_files/md5_unique_filename.jpg

[eluser]Dagobert Renouf[/eluser]
I really don't see the point of the separate directories method.
I mean if it's just the user's avatar, it's unlikely he will need to have more than one, so the unique directory seems perfect to me.

[eluser]Sam Dark[/eluser]
You haven't worked with really huge systems then…

Best practice is not allowing too much files in one directory since *nix can't handle them well.

[eluser]Dagobert Renouf[/eluser]
So you say that if you want to handle 100.000 avatars, the best way to do it is to create 100.000 subfolders ?

In this case, wouldn't it be better to create subfolders that contains 1000 avatars each for example ?

[eluser]Sam Dark[/eluser]
It would be better to divide them. Personally I'm using yyyy/mm/dd folders to store them.

for user icons, i'm using 3-digit folder names (ex: icons/123/) calculated off a user_id, which lets me not only group icons into 999 potential folders, but i can figure out what icon to show based on user_id only. (i also extended the Upload class so I could rename icon files using the user_id.)

Theme © iAndrew 2016 - Forum software by © MyBB