note 54606 added to function.ftp-put

From: Date: Sat, 09 Jul 2005 00:54:00 +0000
Subject: note 54606 added to function.ftp-put
Groups: php.notes 
Request: Send a blank email to php-notes+get-91704@lists.php.net to get a copy of this message
Here is a fix for the function from lucas at rufy dot com below that will recursively put files from a source directory to a destination directory. As written below, it won't put a file in a directory that already exists, because the the destination is altered. So here is the corrected function that will allow it to work: 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_nlist($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 -- http://master.php.net/manage/user-notes.php?action=edit+54606 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+54606&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+54606&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+54606&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+54606&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+54606&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+54606&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+54606&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#91704) next »