The code below works insomuch that I can successfully download the directory recursively. But, I want to download the directories within this directory. So, when it connects it's in . Within the . directory is a subdirectory "In". I want to recursively retrieve the contents within the In directory. The directory names themselves will change, so I can't specify what that's going to be in the script itself... Anyone know how to do this?

ftp_sync ("./In/");    
ftp_close($conn_id); function ftp_sync ($dir) { global $conn_id; if ($dir != ".") { if (ftp_chdir($conn_id, $dir) == false) { echo ("Change Dir Failed: $dir<BR>\r\n"); return; } if (!(is_dir($dir))) mkdir($dir); chdir ($dir); } $contents = ftp_nlist($conn_id, "./In/"); foreach ($contents as $file) { if ($file == '.' || $file == '..') continue; if (@ftp_chdir($conn_id, $file)) { ftp_chdir ($conn_id, ".."); ftp_sync ($file); } else ftp_get($conn_id, $file, $file, FTP_BINARY); } ftp_chdir ($conn_id, ".."); chdir (".."); }

    look at the 2nd user note in the manual for ftp_get() its what you are after.

      That's the code I'm currently using. It copies the In dir recursively, but I don't know how to make it copy the contents within that base directory recursively.

        sorry no idea when your using in as a preposition and when as a dir name.

          dagon;10931922 wrote:

          sorry no idea when your using in as a preposition and when as a dir name.

          Ah. I thought the use of quotes, the word "the", and capitalization of the first letter when referring to the "In" directory made it obvious.... Guess not.

            Write a Reply...