tags:

views:

104

answers:

1

How is one supposed to handle files that aren't in the current directory when using ftp_put? This piece of code is trying to upload a file that I know exists, but it always gives the following error:

"Warning: ftp_put() [function.ftp-put]: Requested action not taken, file not found or no access. in /path/to/files/domains/mydomain.com/html/scriptfile.php on line 1337"

Here's the snip:

$file_name = $this->GetFileName();

  if ($file_name)
  {
    $resource = ftp_connect('ftp.remoteftpserver.com');    

    if ($resource && ftp_login($resource, $username, $pass))
    {
      ftp_pasv($resource, true);
      //UPLOAD_DIRECTORY == '/IN' (it really exists, I'm sure)
      //ORDER_DIRECTORY == /home/domains/mydomain.com/orders (came from $_SERVER['DOCUMENT_ROOT']
      ftp_put($resource, UPLOAD_DIRECTORY . '/' . $file_name, ORDER_DIRECTORY . '/' . $file_name, FTP_ASCII);

      ftp_close($resource);
    }
    else
    {
      echo "FTP Connection Failed!";
    }

  }
A: 

Check the permissions of the remote file. Make sure $username has write access to the file. Make sure you have execute access on the parent directory.

Byron Whitlock