isDir()){ rmdir($file->getRealPath()); } else { unlink($file->getRealPath()); } } rmdir($dir); echo 'Folder deleted'; } else{ /** Informs to the user, what that folder not exists */ echo 'Folder not exists'; } } else{ if ($log==0){ /** If you not are login redirect or more knowledge with 301-302 HTTP ERROR*/ header('Location: ../login.php'); } else{} }