example:
gallery/01/
gallery/02/
gallery/03/
now:
Code: Select all
<?php
rmdir("gallery/01/");
rename("gallery/02/","gallery/01/");
?>
Code: Select all
<?php
rmdir("gallery/01/");
rename("gallery/02/","gallery/01/");
usleep(50000);
?>
*****if you tried to delete a folder with it's contents (sub folders and files) still there, that is a no go. You have to recursively delete the folder and all of it's contents as well. Remember to closedir($***) when $*** is the name of each handle you open for each sub directory (recursive loops in your tree deletion loop).
Code: Select all
<?php
//-----
function delTree($path)
{
//closedir so that it can then be removed per loop
//echo "<h4>delTree $path</h4>";
$handle=opendir($path);
//
if($handle)
{
//
while(false !== ($file=readdir($handle)))
{
//
if($file!="."&&$file!="..")
{
$dirTest=$path."/".$file;
//
if(is_dir($dirTest))
{
delTree($dirTest);
}
else
{
unlink($path.$file);
//echo "$path.$file<br />";
}
}
}
closedir($handle);
}
rmdir($path);
}
//-----
delTree("gallery/01/");
rmdir("gallery/01/");
usleep(50000);//give the OS a chance to finish it's work, there's no return flag for rmdir, etc
rename("gallery/02/","gallery/01/");
?>