note 24264 added to function.ftp-rmdir
| From: | victor59 at mail dot hongkong dot com | Date: | Sun, 11 Aug 2002 10:52:26 +0000 |
| Subject: | note 24264 added to function.ftp-rmdir | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-34804@lists.php.net to get a copy of this message | ||
<?php
function ftp_rmAll(&$ftp_site,$dir){
$root=$dir; // tmp variable
if(@!ftp_chdir($ftp_site,$root)){ // enter the DIRCTORY $root
echo 'Directory not found.';
return 0;
}
if(!empty($dir) && ($file_list=ftp_nlist($ftp_site,'.'))!=0 &&
$file_list!=NULL)
{
// list content inside the DIRECTORY $root
foreach($file_list as $dir) {
if(ftp_size($ftp_site,$dir)===-1){ // dirname
ftp_rmAll($ftp_site,$dir); // recursion
}else {
ftp_delete($ftp_site,$dir); // del file
}
}
}
ftp_chdir($ftp_site,'../'); // dir is empty now, move one level up
if(ftp_rmdir($ftp_site,$root)) // remove the empty dir
return 1;
return 0;
}
?>
This one works well on php4.2.1 + IIS 5.0 + Win 2000 Server
NOTE: $file_list!=NULL is needed in IIS platform
--
http://www.php.net/manual/en/function.ftp-rmdir.php
http://master.php.net/manage/user-notes.php?action=edit+24264
http://master.php.net/manage/user-notes.php?action=delete+24264
http://master.php.net/manage/user-notes.php?action=reject+24264