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


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to