我需要使用 php 中的 ftp 函数将 csv 文件上传到实时服务器
我的代码
$local_filename = $_SERVER['DOCUMENT_ROOT'].'/feeds/ftp/xyz.csv';
$remote_filename = date('Y-m-d_').'data.csv';
$ftp_server = 'sftp.myhost.com';
$ftp_user_name = 'username';
$ftp_user_pass = 'password';
$conn_id = ftp_connect($ftp_server,22);
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
if (ftp_put($conn_id, $remote_filename, $local_filename, FTP_ASCII)) {
unlink($local_filename);
$res = true;
} else {
$res = false;
}
ftp_close($conn_id);
我得到了这个:
Warning: ftp_login() expects parameter 1 to be resource, boolean given in C:\wamp\www\fstp\index.php on line 11
如何解决此错误?