Any idea how a photo upload site save photos there?

its more related to the question related to architecture, sorry if I ask in the wrong stack.

do they put them in a big pile in a folder? as

$ uid. $ md5 (random). $ name save in one folder

folder/5231.124wdadace123214.arandomname.jpg folder/42.15125dawdaowdaw232.arandom2name.png folder/etc 

or

$ UID / $ md5 (random). $ Name

 5231(uid)/12421adwawda2321.arandomname.jpg 42/15125awdawdwadwa232.arandom2name.png etc/2323awdwadwadaw.logo.png 

what does he think here, the second is better?
, because in windows I have many photos in one folder
and yes, it takes time to open it.

Do you guys know how they store files?

+4
source share
5 answers

I wrote a function for my sites that converts user IDs into a hierarchy of two-level subdirectory, which limits the subdirectories to 1000 at each level.

 function get_image_dir($gid) { $d = str_split(str_pad($gid, 6, "0", STR_PAD_LEFT), 3); $wdir = "/images/members/" . $d[0] . "/" . $d[1] . "/" . $gid; return $wdir; } 

(In fact, I am adding a third level with a raw user ID to process the 1,000,000 survey.

 /images/members/000/001/1 /images/members/000/002/2 ... /images/members/999/999/999999 /images/members/000/000/1000000 /images/members/000/001/1000001 

In these subdirectories, I further separate based on

  • albums (organized by members)
  • various changes (for different places on the site

The final structure looks something like this:

 /images/members/000/001/1/album1/original /images/members/000/001/1/album1/50x50 /images/members/000/001/1/album1/75x75 /images/members/000/001/1/album1/400x300 

The str_split(str_pad()) function in the function is probably not optimal, but at the moment it works.

+1
source

It depends mainly on the file system. For a modern file system, such as NTFS or ext3, storing a huge number of files in one directory is not a problem, but some older file systems cannot handle it.

However, it might still be a good idea to split the files into subdirectories according to some kind of scheme, just so that they can be managed using various tools (which can have their problems with huge directories) such as backing up. By the way, opening a directory in Windows Explorer is considered such a case.

+1
source

it depends on how many images you expect to have if we talk about thousands of photos stored in different folders so that the computer can scan the directory for the file

0
source

How do I do this, use a folder containing identifier numbers,

 /img/0-100/1 /img/101-200/102 

This will give you an easy way to search for your images, and the folder will remain quite small. And there is no extension because I save this in the database.

0
source

Yes, a large number of files in one folder can slow down the work with files in this folder. At least in the main OS. Theoretically, this should not be so.

Other sites also use the date. Not just user identifiers or image identifiers. Another way to do the same.

0
source

All Articles