note 24264 deleted from function.ftp-rmdir by aidan
| From: | aidan@php.net | Date: | Fri, 29 Jul 2005 07:08:48 +0000 |
| Subject: | note 24264 deleted from function.ftp-rmdir by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-92696@lists.php.net to get a copy of this message | ||
Note Submitter: victor59 at mail dot hongkong dot com
----
<?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