mercredi 2 janvier 2019

How to generate a unique folder name with mt_rand()?

I want to generate a random/unique folder name. The result of mt_rand(1000000,100000000) will be the unique folder name to each registred user. Could some one help?

if(isset($_POST['register'])){    
    $FolderName = 'user/'.mt_rand(1000000,100000000).'/img';

    if(is_dir($FolderName)){
        $folderUnique = //i have no idea what i should put here
    }elseif(!is_dir($FolderName)){
        $folderUnique = $FolderName;
    }

    $folder = mkdir($folderUnique, 0777, true);
    ...
    ...
    ...
}




Aucun commentaire:

Enregistrer un commentaire