I have a script that creates a directory when an image is uploaded and places it there.
Right now I am writing a script that will delete some records and I need a script that will delete that image directory with the uploaded image. I came across a function in the manual php.net but it doesn't seem to be able to remove the directory. Directory CHMOD 755, but when I try to delete it via FTP browser, I get permission denied message. I think it's something to do with the way the directory was created. I have to login as an administrator to mysever to remove it.
How can I modify the function to obvercome this issue?
Here's the function I've attempted to use:
function full_rmdir($dirname)
{
if ($dirHandle = opendir($dirname))
{
$old_cwd = getcwd();
chdir($dirname);
while ($file = readdir($dirHandle))
{
if ($file == '.' || $file == '..') continue;
if (is_dir($file))
{
if (!rmdir_rf($file)) return false;
}
else
{
if (!unlink($file)) return false;
}
}
closedir($dirHandle);
chdir($old_cwd);
if (!rmdir($dirname)) return false;
return true;
}
else
{
return false;
}
}