I'm trying to delete folders on my website that were created using a script.
The code being used to create the folders is simply:
mkdir($new_folder, 0755);

The code I'm using to delete the folder is:
$rmdir = "rm -rf $path";
$rmdir;
if($rmdir) {
echo $path." deleted<BR>";
} else {
echo $path." not deleted<BR>";
}

Also, rmdir($path) doesn't work. Can I modify the script so that the folder gets deleted or do I need to make some changes to php.ini or other server file?

    If you create new directories using 0777 permissions, will the rm -rf work then?

    Other than that, double check your path? When you say it "doesn't work", are you getting any error messages? Have you set display_errors to On and error_reporting to E_ALL ?

      Note: When safe mode is enabled, PHP checks whether the directory in which you are about to operate has the same UID (owner) as the script that is being executed.

        Well it turns out some functions were being disabled in php.ini which were preventing my code from working. The code works now.

        Thanks.

          Write a Reply...