我需要将文件从本地计算机自动上传到远程服务器。我在这里找到了以下代码:
<?php
require_once('ftp.php');
// set up basic connection
$conn_id = ftp_connect($ftp_server);
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// upload a file
if (ftp_put($conn_id, $remote_file, $file, FTP_ASCII)) {
echo "successfully uploaded $file\n";
exit;
} else {
echo "There was a problem while uploading $file\n";
exit;
}
// close the connection
ftp_close($conn_id);
?>
ftp.php
是我的带有 ftp 身份验证信息的文件。连接有效,但我收到以下错误:
There was a problem while uploading C:/xampp/htdocs/testbcos/accounting/checkslastmonth.csv
编辑:我不确定这是否有所不同,但这里是我的 $remote_file 和我的 $file:
$file = "C:/xampp/htdocs/testbcos/accounting/checkslastmonth.csv";//tobe uploaded
$remote_file = "/home/bookcell/public_html/testbcos/accounting/checkslastmonth3.csv";
我在这里做错了什么?此外,如果文件位于本地服务器上的映射驱动器上,是否可以执行此操作?谢谢。