note 25477 added to function.ftp-put

From: Date: Wed, 25 Sep 2002 10:43:16 +0000
Subject: note 25477 added to function.ftp-put
Groups: php.notes 
Request: Send a blank email to php-notes+get-37226@lists.php.net to get a copy of this message
If you want to copy a whole directory tree (with subdiretories), this function (ftp_copy) might be usefull. Tested with php 4.2.2 and a Linux OS. Example: ---------------------------------------------------------------- $conn_id = ftp_connect("server_adress"); ... $src_dir = "/from"; $dst_dir = "/to"; ftp_copy($src_dir, $dst_dir); ... ftp_close($conn_id) Function: ftp_copy() ---------------------------------------------------------------- function ftp_copy($src_dir, $dst_dir) { global $conn_id; $d = dir($src_dir); while($file = $d->read()) { if ($file != "." && $file != "..") { if (is_dir($src_dir."/".$file)) { if (!@ftp_chdir($conn_id, $dst_dir."/".$file)) { ftp_mkdir($conn_id, $dst_dir."/".$file); } ftp_copy($src_dir."/".$file, $dst_dir."/".$file); } else { $upload = ftp_put($conn_id, $dst_dir."/".$file, $src_dir."/".$file, FTP_BINARY); } } } $d->close(); } -- http://www.php.net/manual/en/function.ftp-put.php http://master.php.net/manage/user-notes.php?action=edit+25477 http://master.php.net/manage/user-notes.php?action=delete+25477 http://master.php.net/manage/user-notes.php?action=reject+25477

« previous php.notes (#37226) next »