Reputation: 23379
I have a class that handles FTP stuff located here:
/var/www/html/crm/rhinos/classes/ftp.php
This class is included in a script that generates a spreadsheet here:
/var/www/html/crm/send_cust_lock.php
The generated spreadsheet is located here:
/var/www/html/crm/tmp/cust_lock_1430424215.xlsx
My class contains the following method:
public function put($filepath){
$fp = fopen($filepath, 'r');
$z = ftp_fput($this->connection, $filepath, $fp, FTP_BINARY);
fclose($fp);
return $z;
}
From my send_cust_lock.php
script, when I call $ftp->put($fn);
($fn
being the above filepath to the spreadsheet), I get the following error:
Warning: ftp_fput(): Can't open that file: No such file or directory in /var/www/html/crm/rhinos/classes/ftp.php on line 62
fopen()
does not throw an error, so why does ftp_put()
throw one?
I have tried converting the path to a relative path using the function in the chosen answer here, but no luck. How can I convert the filepath to something that ftp_put()
can recognise?
Upvotes: 0
Views: 504
Reputation: 24549
The manual says the values are:
ftp_fput ( resource $ftp_stream , string $remote_file , resource $handle , int $mode [, int $startpos = 0 ] )
And you are passing:
$z = ftp_fput($this->connection, $filepath, $fp, FTP_BINARY);
Where your $fp
is a handle to the local file as expected, but why are you passing the same path as the $remote_file
? It's not going to find it on the remote FTP since you passed the local file name.
Upvotes: 3