note 45646 added to function.ftp-rmdir
| From: | nate at 8networks dot com | Date: | Tue, 14 Sep 2004 00:31:51 +0000 |
| Subject: | note 45646 added to function.ftp-rmdir | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-76650@lists.php.net to get a copy of this message | ||
The post by lucas at rufy dot com did not correctly perform recusion. I simply changed the marked
line to include the directory path to illiminate problems on different systems.
<?
function ftp_rmAll($conn_id,$dst_dir){
$ar_files = ftp_nlist($conn_id, $dst_dir);
if (is_array($ar_files)){ // makes sure there are files
for ($i=0;$i<sizeof($ar_files);$i++){ // for each file
$st_file = $ar_files[$i];
if (ftp_size($conn_id, $st_file) == -1){ // check if it is a directory
ftp_rmAll($conn_id, $dst_dir."/".$st_file); // if so, use recursion ****
THIS IS WHERE THE CHANGE IS *****
} else {
ftp_delete($conn_id, $st_file); // if not, delete the file
}
}
Thanks,
Nate Hall
nate (at) 8networks (dot) com
8Networks, Inc
}
ftp_rmdir($conn_id, $dst_dir); // delete empty directories
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.ftp-rmdir.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+45646
Delete -- http://master.php.net/manage/user-notes.php?action=delete+45646&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+45646&report=yes
Search -- http://master.php.net/manage/user-notes.php