So I am working with this function, that works great...

but right now, it overwrites files on the remote website, and instead, I want it to ignore files that already exist...

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
               if (!$upload) echo 'FTP upload failed!';
               echo ". ";
           }
       }
   }
   $d->close();

any tips would be great.

    You want the function to do the work?

    If this is called in a script, why not just wrap it in a conditional?

    (PS > It's after 5 PM here, and a long day ... if this doesn't make sense, I'm sorry).

      I think he means use something like the file_exists() function to test whether the file exists or not and go from there rather than code all the checking within the function.

        Perhaps you can use ftp_mdtm or ftp_size.

          Write a Reply...