Ok i have come up with this. I have not tested it yet but i am pretty sure it will work.
$fID = $_POST['fID'];
$mailPath = "../temp/".$fID."/mail";
$tempNudPath = "../temp/".$fID."/nudity";
$tempCleanPath = "../temp/".$fID;
$cleanPath = "../media/modelapps/".$moveID;
$nudPath = "../media/modelapps/".$moveID."/nudity";
if (!is_dir($cleanPath) || !is_dir($nudPath)) {
mkdir($cleanPath,0777);
mkdir($nudPath,0777);
}
if ($handleMail = opendir($mailPath)) {
while (false !== ($fileMail = readdir($handleMail))) {
if ($fileMail != "." && $fileMail != "..") {
$delMail=unlink($mailPath."/".$fileMail);
}
}
closedir($handleMail);
rmdir($mailPath);
}
if ($handleNud = opendir($tempNudPath)) {
while (false !== ($fileNud = readdir($handleNud))) {
if ($fileNud != "." && $fileNud != "..") {
rename($tempNudPath."/".$fileNud, $nudPath."/".$fileNud);
$delNud=unlink($tempNudPath."/".$fileNud);
}
}
closedir($handleNud);
rmdir($tempNudPath);
}
if ($handleClean = opendir($tempCleanPath)) {
while (false !== ($fileClean = readdir($handleClean))) {
if ($fileClean != "." && $fileClean != "..") {
rename($tempCleanPath."/".$fileClean, $cleanPath."/".$fileClean);
$delClean = unlink($tempCleanPath."/".$fileClean);
}
}
closedir($handleClean);
rmdir($tempCleanPath);
}
If it can be better coded then please advise.