Sander Korst - 2013-05-06 01:59:43
Hi There,
I hope someone here can help me out with this crazy error.
The situation is as following:
In a script I create folder A. Then in this folder I place 2 .xls files, and 1 subfolder (folder B) that contains several images.
Then at the end of the script I run the following code to delete all files and subfolders (for the record, the script works, and I tried several other working script too. But to be sure):
function deleteDirectory($dir) {
if (!file_exists($dir)) return true;
if (!is_dir($dir)) return unlink($dir);
foreach (scandir($dir) as $item) {
if ($item == '.' || $item == '..') continue;
if (!deleteDirectory($dir.DIRECTORY_SEPARATOR.$item)) return false;
}
return rmdir($dir);
}
After this, I do the rmdir($folder_A) to remove it.
And then it happens: I get the error "Warning: file exists in Folder A" and it doesnt delete it.
But when I look in the folder via my ftp program, the folder is EMPTY (folder B is gone, and so are all the files) and 0 bytes. When I run another script which contains only the "rmdir($folder_A)" at this point, it removes the folder without any problems.
How is this possible? What happens?
I really really hope that someone has some genius idea of what this could be... Thanks a lot in advance!
PS: The folders A and B have the same rights (750) and they where within the same script.