我在我的本地有文件,我想在特定文件夹上的ftp服务器上传该文件,但我无法做到,任何人都可以对它有所了解。以下是我的代码。
$ftp = ftp_connect("server path",22);
ftp_login($ftp,username,password);
$ret = ftp_nb_put($ftp,
"/incoming/in/",
"http://localhost:8888/cardManagement/newfile.dat",
FTP_BINARY,
FTP_AUTORESUME);
print_r($ret);
注意 - 它的SFTP
答案 0 :(得分:-1)
$strServer = "##";
$strServerPort = "22";
$strServerUsername = "##";
$strServerPassword = "##";
//connect to server
$sftp = new Net_SFTP($strServer);
if (!$sftp->login($strServerUsername, $strServerPassword)) {
exit('Login Failed');
}
// puts a three-byte file named filename.remote on the SFTP server
$sftp->put('/incoming/'.$fileName, $fileName);
// puts an x-byte file named filename.remote on the SFTP server,
// where x is the size of filename.local
$sftp->put('/incoming/in/'.$fileName, $fileName, NET_SFTP_LOCAL_FILE);