I uploaded a file with this script, and the filename contained an apostrophe. The script forced a backslash ("\") before the apostrophe, and now I can't delete that file from my server because the server doesn't recognize the backslash.
Thanks for pointing that out. The code below should fix this problem. Sorry if it caused any problems. You may can ask your host to remove the file for you if you can't?
function rand_name($original) { $original = preg_replace('/[^\w\s\-\.]/', null, $original);
/* Recursive mkdir function
** @param string dirName
** @param int rights
*/
function mkdir_r($dirName, $rights)
{
$dirs = explode('/', $dirName);
$dir='';
foreach ($dirs as $part)
{
$dir.=$part.'/';
if (!is_dir($dir) && strlen($dir)>0)
{
mkdir($dir, $rights);
}
}
}
--
Chris Gmyr
www.chrisgmyr.com
www.syracusecs.com
www.syracusebands.net
Now what?!
function rand_name($original)
{
$original = preg_replace('/[^\w\s\-\.]/', null, $original);
if ($this->overwrite OR !file_exists($this->upload_path . $this->subdir . $original))
{
return $original;
}
else
{
return $this->rand_name(substr(md5(rand(1, 5000) . time()), -5) .'_'. $original);
}
}