FTP problem..
| From: | Chad Day | Date: | Tue, 24 Apr 2001 14:10:58 +0000 |
| Subject: | FTP problem.. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-50076@lists.php.net to get a copy of this message | ||
I'm trying to write a script to ftp the contents of one directory structure
onto another server.. I'm having problems recursing the directories, either
it a) doesn't do it or b) gets stuck in a loop.
Here's the function I'm having the problem with..
function recurseUp()
{
global $conn_id, $recurse;
$handle=opendir('.');
while (false!==($file = readdir($handle))) {
if ($file != "." && $file != "..")
echo "<br><b>$file</b><br>";
{
//if dir then recurse
if (is_Dir($file)) {
chDir($file);
$result = ftp_chdir($conn_id, $file);
if (!$result) {
@ftp_mkdir($conn_id, $file);
$result = ftp_chdir($conn_id, $file);
}
recurseUp();
} else {
//put
$result = ftp_put($conn_id, $file, $file, FTP_BINARY);
if (!$result) {
echo "<BR><b>Error attempting retrieve file: $file</b>";
} else {
echo "<BR>Remote File Successfully Saved as: $file";
}
}
}
}
chDir('c:\inetpub\wwwroot\php\xfer');
ftp_cdup($conn_id);
closedir($handle);
}
Does anyone see the problem? Thanks!
Chad