我有一个处理FTP内容的类,位于这里:
/var/www/html/crm/rhinos/classes/ftp.php此类包含在生成电子表格的脚本中:
/var/www/html/crm/send_cust_lock.php生成的电子表格位于以下位置:
/var/www/html/crm/tmp/cust_lock_1430424215.xlsx我的类包含以下方法:
public function put($filepath){
$fp = fopen($filepath, 'r');
$z = ftp_fput($this->connection, $filepath, $fp, FTP_BINARY);
fclose($fp);
return $z;
}从我的send_cust_lock.php脚本中,当我调用$ftp->put($fn); ($fn是电子表格的上面的文件)时,我得到以下错误:
Warning: ftp_fput(): Can't open that file: No such file or directory in /var/www/html/crm/rhinos/classes/ftp.php on line 62fopen()不会抛出错误,那么为什么ftp_put()会抛出一个错误呢?
我尝试使用所选答案这里中的函数将路径转换为相对路径,但没有成功。如何将文件转换为ftp_put()可以识别的内容?
发布于 2015-04-30 20:15:56
手册表示,这些值是:
ftp_fput ( resource $ftp_stream , string $remote_file , resource $handle , int $mode [, int $startpos = 0 ] )你要经过:
$z = ftp_fput($this->connection, $filepath, $fp, FTP_BINARY);您的$fp是本地文件的句柄,但为什么要传递与$remote_file相同的路径?它不会在远程FTP上找到它,因为您传递了本地文件名。
https://stackoverflow.com/questions/29976977
复制相似问题