我想将csv feed上传到公共ftp。将文件上传到ftp时出错
我有这样的:
global $_CONFIG;
$host = $_CONFIG['po']['ftp']['server'];
$username = $_CONFIG['po']['ftp']['username'];
$password = $_CONFIG['po']['ftp']['password'];
$ftp_path = $_CONFIG['po']['ftp']['upload_path'];
$file = $export_file;
$fp = fopen($export_file, 'r+');
// set up basic connection
$conn_id = ftp_connect($host);
// login with username and password
$login_result = ftp_login($conn_id, $username, $password);
// try to upload $file
if (ftp_fput($conn_id, $ftp_path, $fp, FTP_BINARY)) {
echo "Successfully uploaded $file\n";
exit;
} else {
echo "There was a problem while uploading $file\n";
exit;
}
// close the connection and the file handler
fclose($fp);
ftp_close($conn_id);
主机,用户,密码是否正确。导出文件是D:/some path .csv
问题在于ftp服务器上的文件被称为.upload.somefile.csv
(并且它不具有完整的大小)。
ftp_path是/somefile.csv
。
我究竟做错了什么?
尝试'ftp_pasv($ conn_id,true);'。 – Passerby 2013-03-07 09:50:42