note 66097 added to function.ftp-rmdir
| From: | mailatmartinauerdotnet at osu1 dot php dot net | Date: | Sun, 14 May 2006 17:36:38 +0000 |
| Subject: | note 66097 added to function.ftp-rmdir | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-111274@lists.php.net to get a copy of this message | ||
At least in PHP 4.3.11 ftp_nlist lists complete paths, not just filenames. Therefore the function by
uma at di4 dot com did not work for me. But it worked with a small change in line 6 like this:
function ftp_rmAll($conn_id,$dst_dir){
$ar_files = ftp_nlist($conn_id, $dst_dir);
//var_dump($ar_files);
if (is_array($ar_files)){ // makes sure there are files
for ($i=0;$i<sizeof($ar_files);$i++){ // for each file
$st_file = basename($ar_files[$i]);
if($st_file == '.' || $st_file == '..') continue;
if (ftp_size($conn_id, $dst_dir.'/'.$st_file) == -1){ // check if it is a
directory
ftp_rmAll($conn_id, $dst_dir.'/'.$st_file); // if so, use recursion
} else {
ftp_delete($conn_id, $dst_dir.'/'.$st_file); // if not, delete the file
}
}
}
$flag = ftp_rmdir($conn_id, $dst_dir); // delete empty directories
//return $flag;
}
----
Server IP: 192.35.244.50
Probable Submitter: 80.108.94.183
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.ftp-rmdir.php
Edit -- http://master.php.net/note/edit/66097
Del: integrated -- http://master.php.net/note/delete/66097/integrated
Del: useless -- http://master.php.net/note/delete/66097/useless
Del: bad code -- http://master.php.net/note/delete/66097/bad+code
Del: spam -- http://master.php.net/note/delete/66097/spam
Del: non-english -- http://master.php.net/note/delete/66097/non-english
Del: in docs -- http://master.php.net/note/delete/66097/in+docs
Del: other reasons-- http://master.php.net/note/delete/66097
Reject -- http://master.php.net/note/reject/66097
Search -- http://master.php.net/manage/user-notes.php