通过FTP错误上传文件

时间:2016-12-27 12:09:42

标签: php file ftp copy

代码:

$file = '/export/clients.xml';
$remote_file = '/clients.xml';
$ftp_server = "ftp://my.address.com";
$ftp_user_name = "user";
$ftp_user_pass = "password";

$conn_id = ftp_connect($ftp_server);
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

if (ftp_put($conn_id, $remote_file, $file, FTP_ASCII)) {
 echo "successfully uploaded $file\n";
} else {
 echo "There was a problem while uploading $file\n";
}

ftp_close($conn_id);

现在原始文件路径为:ftp://my@address.com/domains/website.com/public_html/export/clients.xml

我应该如何编写文件路径以便完成文件传输?我希望将文件复制到我的FTP服务器的根目录中。但它没有这种方式。

1 个答案:

答案 0 :(得分:0)

问题是FTP服务器名称。我删除了ftp://部分,现在它正在工作。