Function Get Error
| From: | difenza2003\@libero\.it | Date: | Fri, 03 Sep 2004 07:53:34 +0000 |
| Subject: | Function Get Error | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-195691@lists.php.net to get a copy of this message | ||
I write this function to delete directory and file but when i 've a directory not empty i get
error
The code that i write is this:
function DelDir($dir) {
if (!($handle = opendir($dir)))
die("Error, it's not possible open $dir");
while($file = readdir($handle) !== false) {
if ($file != '.' && $file != '..') {
if (is_dir("$dir/$file")) {
DelDir("$dir/$file");
rmdir("$dir/$file");
}
else {
unlink("$dir/$file");
}
}
}
closedir($handle);
if (!(rmdir("$dir"))) {
die("It's not possible Del <b>$dir</b>");
}
else {
echo("It's okay");
}
}
DelDir('my_folder');
I receive this warning:
Warning: rmdir(cartella): Directory not empty in c:\programmi\apache
group\apache\users\test\project\delete.php on line 23
I have set chmod on linux chmod to 777 but i can delete folder only when is empty.
What I do ?
Thanks to all and sorry for my bad language.