Hi,
The project I'm working on needs to FTP a file to a remote host if it sees that the required file does not exist.I presumed that I would use ftp_mdtm command about that but my server does not support it.Could anyone give some suggestions?

-Thanks

    You could use ftp_nlist() and see if the filename in question is in the returned array.

      Hi Grumbler/Anyone

      It appears that I'm doing something wrong with the ftp_nlist nothing gets listed as the files though I know files exist.Do you see something wrong?

      $remotehomedir = ftp_pwd($conn);

      $filesindir=Array();
      $filesindir = ftp_nlist($conn,$remotehomedir)."<BR>";

      $i=0;

      foreach ($filesindir as $filename)
      echo "File : $filename<br>";

      _thanks

        Be careful when using the ftp_nlist function.

        Function returns false on error, but also returns false if the directory is empty.

          Ya I see that ftp_nlist is returning 0 but files are there in it.Do you know reasons why that may occur.I'm changing the remote directory to different values ,still the same value 0.

          I belive since it can recognise the directory the permissions should not be a matter?

            Got to work using this code found on the forum by not specifying the entire dir path.

            $files=ftp_rawlist($id, "");
            foreach($files as $file) {
            echo substr($file,55)."<br>\n";
            }

            -Thanks

              Drop that ."<br>" bit - you're turning the array into a string.

                Write a Reply...