I'm wondering if it might be an awful idea to produce a folder for each user. So any images for every user could be utilized with img.mysite.com/UserId/image.digital

This might come to be a large number of sites, so be careful as some filesystems limit the amount of subdirectories in one directory. It's quite common to interrupt up produced content into multiple sites. You could do this it by date, or split up some identifier (a hash, or even the image's autoincremented ID number) to produce a much deeper directory structure. Example:

  • avatars/000/ (images 1-999)
  • avatars/001/ (images 1000-1999)
  • avatars/002/ (images 2000-2999)

Also known as your directory prefix is floor(ID / 1000).

There's most likely a situation for abstracting your URIs out of your filesystem anyway, therefore it does not really matter in which the files are saved around the after sales, except for you like a programmer.

No, it isn't the very best idea.

When the only reason for the separate folders is to ensure that you could have 'friendly' Web addresses within the structure you suggest, then I suggest you look for URL Spinning rather.

If you are attempting to solve another problem, publish a comment and tell us.

Absolutely bad idea I'll say from my experience
In recent past I had been focusing on one application which took it's origin from social media
And contains around 15000+ customers now.

Also I'm controlling that website presently.

Issues with this really is you will discover it awesome in the beginning to handle but later it will likely be a problem.
Also have to keep an eye on permissions.
Creation and deletion of folder regarding your database to attain synchronisation.
Also If you're on hosting that is shared, many hosting companies they do not show all of the folders with any File Manager.Most of folder that may be seen through File Managers is 2000 with customer service give you support only obtain access to first 10000 folder. Also Non-Ascii reputation for folder will as those of database is going to be another problem.

Which is an excellent problem for you personally later.

I'll suggest not to choose by doing this without a doubt.

You will find frameworks which use clean web addresses, better use that. Your idea is... well... terrible...

Zend for instance uses clean web addresses, which means you would get access to images with:

world wide web.example.com/userid/imagename/

Pointless why it might be an problem from the performance reason. From an business perspective, it's cleaner than simply tossing them altogether in to the same folder.

I believe this is better format:

You'll be able to do database such as this:

tables users and imgs

Play one folder in your ftp making a good and solid database where all photos of the identical person are linked together. Not too hard :)

For any more compact site, it isn't a dreadful idea, with one caveat:

You MUST abstract the file creation/deletion handling into one mechanism!

Make certain that your code uses this mechanism, that ought to have the ability to store and retrieve and remove, and that is it. Then, later on, if you wish to change the way you store your files, it can be done really easily.

P.S. When I only say all of your code, I truly mean all your code. For example, I'd have Have that matches


handled with a single method, which calls the mechanism I referred to above.