[FTP] suppression de fichier récursive d'un dossier
Bonjour
je cherche à créer une fonction de suppression récursive avec unlink() et rmdir();
Voici ma fonction :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
function del_tree ($path) {
if (is_dir($path))
{
if ($dh = @opendir($path)) {
while (($file = readdir($dh)) !== false) {
if (($file != '.') && ($file != '..') && ($file != '...'))
if (is_dir($path . $file))
{
del_tree ($path . $file ."/");
}
else
{
unlink ($path . $file);
}
}
closedir($dh);
}
rmdir ($path);
}
elseif (is_file($path))
{
unlink ($path);
}
} |
Elle supprime tous les fichier, mais pas les dossier :-(
Je sais pas trop comment me débrouiller avec le rmdir();
Merci