note 34690 added to function.ftp-rmdir

From: Date: Mon, 04 Aug 2003 06:51:06 +0000
Subject: note 34690 added to function.ftp-rmdir
Groups: php.notes 
Request: Send a blank email to php-notes+get-53307@lists.php.net to get a copy of this message
The following function has been fully tested to recursively delete files through FTP. It is based on a previous post which did not fully work as posted. See http://rufy.com/tech/archives/000026.html for more information. NOTE: use full path name for the destination directory 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, $st_file); // if so, use recursion } else { ftp_delete($conn_id, $st_file); // if not, delete the file } } } ftp_rmdir($conn_id, $dst_dir); // delete empty directories } ---- Manual Page -- http://www.php.net/manual/en/function.ftp-rmdir.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+34690 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+34690&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+34690&report=yes

« previous php.notes (#53307) next »