note 34688 added to function.ftp-put

From: Date: Mon, 04 Aug 2003 06:45:01 +0000
Subject: note 34688 added to function.ftp-put
Groups: php.notes 
Request: Send a blank email to php-notes+get-53305@lists.php.net to get a copy of this message
The following is a fully tested function (based on a previous note) that recursively puts files from a source directory to a destination directory. See http://rufy.com/tech/archives/000026.html for more information. NOTE: use full path name for the destination directory and the destination directory must already exist function ftp_putAll($conn_id, $src_dir, $dst_dir) { $d = dir($src_dir); while($file = $d->read()) { // do this for each file in the directory if ($file != "." && $file != "..") { // to prevent an infinite loop if (is_dir($src_dir."/".$file)) { // do the following if it is a directory if (!@ftp_chdir($conn_id, $dst_dir."/".$file)) { ftp_mkdir($conn_id, $dst_dir."/".$file); // create directories that do not yet exist } ftp_putAll($conn_id, $src_dir."/".$file, $dst_dir."/".$file); // recursive part } else { $upload = ftp_put($conn_id, $dst_dir."/".$file, $src_dir."/".$file, FTP_BINARY); // put the files } } } $d->close(); } ---- Manual Page -- http://www.php.net/manual/en/function.ftp-put.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+34688 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+34688&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+34688&report=yes

« previous php.notes (#53305) next »