php - any idea how pics upload site save there pics? -
its more architecture related question, sorry if ask in wrong stack.
do put them in large pile im folder ? like
$uid.$md5(random).$name save in 1 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 im thinking here second 1 better?
because @ windows have lot of pics in 1 folder
, yes takes time open it.
do guys have idea how keep files ?
i wrote function sites converts user ids 2 level subdirectory hierarchy limits subdirectories 1000 @ 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; }
(i add third level raw user id handle rollover @ 1,000,000.
/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
within subdirectories, further segregate based on
- albums (organized members)
- various resizings (for different places on site
final structure looks like
/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())
in function isn't optimal, works.
Comments
Post a Comment