note 18790 deleted from function.mkdir by aidan

From: Date: Sun, 03 Oct 2004 13:40:50 +0000
Subject: note 18790 deleted from function.mkdir by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-77847@lists.php.net to get a copy of this message
Note Submitter: function at NOSPAMworldonline dot dk ---- To create a unique directory somewhere: Returns directory name or false on error. define("CLIENT_PATH", "the_path_for_the_directory/"); function getUniqueDirectory() { $dir = getRandString(); if (is_dir(CLIENT_PATH.$dir)) return getUniqueDirectory(); $oldumask = umask(0); $result = mkdir(CLIENT_PATH.$dir, 0777); umask($oldumask); if (!$result) return false; return $dir; } function getRandString($length = 8) { $pool = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; $pool .= "abcdefghijklmnopqrstuvwxyz"; srand(time()); for($index = 0; $index < $length; $index++) $sid .= substr($pool,(rand()%(strlen($pool))), 1); return($sid); }

« previous php.notes (#77847) next »