rmdir not working on empty folder
Posted: Thu Mar 16, 2017 5:08 pm
Hi Celauran,
Spent a few hours trying to research this to no avail. Thought I would run it by you to see if you catch the problem.
Trying to delete an empty folder that is:
1. Known to be completely empty
2. Permission'd with 0777
The file in the folder does delete properly on both localhost and server, but folder doesn't delete on localhost or server.
I tried manually creating a folder on the server and gave it 0777 permissions. After trying to delete it with the script above, I noticed the permisssions were changed to 0777.
I hard-coded the folder "Tom-Jones" just as a test. I also used getcwd() to ensure I was calling script from proper location.
Localhost is using UniServer (localhost) on Windows 10, but I don't think it's a path issue anymore.
Thanks for any help you can provide.
Michael
Spent a few hours trying to research this to no avail. Thought I would run it by you to see if you catch the problem.
Trying to delete an empty folder that is:
1. Known to be completely empty
2. Permission'd with 0777
Code: Select all
if(isset($_GET['delete_photo'])) {
$document_folder = $_SESSION['student_first_name'] . "-" . $_SESSION['student_last_name'];
$target_dir = "../_photos/".$document_folder."/";
$folder_check = $target_dir;
if (file_exists($folder_check)) {
array_map('unlink', glob("$target_dir/*.*")); //THIS WORKS FINE
$handle = opendir($target_dir); // DIDN'T MAKE ANY DIFFERENCE
closedir($handle); // DIDN'T MAKE ANY DIFFERENCE
rmdir("../_photos/Tom-Jones"); // NO-GO ON LOCALHOST OR SERVER
}
}
I tried manually creating a folder on the server and gave it 0777 permissions. After trying to delete it with the script above, I noticed the permisssions were changed to 0777.
I hard-coded the folder "Tom-Jones" just as a test. I also used getcwd() to ensure I was calling script from proper location.
Localhost is using UniServer (localhost) on Windows 10, but I don't think it's a path issue anymore.
Thanks for any help you can provide.
Michael