I\'m thinking about developing my own PHP based gallery for storing lots of pictures, maybe in the tens of thousands.
At the database I\'ll point to the url of the i
When saving files associated with an auto_increment ids, I use something like the following, which creates three directory levels, each comprised of 1000 dirs, and 100 files in each third-level directory. This supports ~ 100 billion files.
if $id = 99532455444 then the following returns /995/324/554/44
function getFileDirectory($id) {
$level1 = ($id / 100000000) % 100000000;
$level2 = (($id - $level1 * 100000000) / 100000) % 100000;
$level3 = (($id - ($level1 * 100000000) - ($level2 * 100000)) / 100) % 1000;
$file = $id - (($level1 * 100000000) + ($level2 * 100000) + ($level3 * 100));
return '/' . sprintf("%03d", $level1)
. '/' . sprintf("%03d", $level2)
. '/' . sprintf("%03d", $level3)
. '/' . $file;
}