idea for id storing of files

If you have some time of id in your database and you want to save file associated with this id it’s not a good idea to make dir with id value and save the file there because on some point you will have too much dirs with same name.

For this if the id is 123456 we can create dir from the id but separating all digit in subdir like 1/2/3/4/5/6/file/file.jpg

The last one dir is called file because we can have 1234567 and then in this dir we will have subdir 😉

function gen_id_to_folder_name($id){

$split = str_split($id);

foreach($split as $spl){
$folder_name .=$spl.“/“;
}

return $folder_name.“c/“;
}

С етикет: , , , , , ,
Публикувано в linux, php

Вашият коментар

Вашият имейл адрес няма да бъде публикуван.

*