将上载的文件移动到远程服务器上


Moving an uploaded file onto a remote server

我正试图将上传的文件移动到远程服务器上,但这不起作用;

move_uploaded_file($tmp_name,"上传/$code1/$code.$fileex");

$ftp_server = "IP";
$ftp_user_name = "username";
$ftp_user_pass = "password";
$file = $tmp_name;
$remote_file = "/public_html/test/uploads/";
// 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";
} else {
 echo "There was a problem while uploading $file'n";
}
// close the connection
ftp_close($conn_id);

我明白了;

警告:ftp_put()[function.ftp put]:无法打开该文件:是第52行/home/file/public_html/uploaded.php中的目录

$remote_file变量指向一个文件时,它却指向一个目录。尝试将$remote_file更改为$remote_file = "/public_html/test/uploads/".$file;

您可能应该将上传文件的部分包装在if语句中,该语句检查您是否真正正确连接到FTP

此外,上传文件时,需要文件1和文件2。现在您已经提供了文件2和一个目录。

http://php.net/manual/en/function.ftp-put.php

您试图移动到的文件是目录"/public_html/test/uploads/",您需要将文件名和扩展名附加到该目录上。

在/etc/vsftpd.conf文件的末尾添加以下行

添加pasv_prociscous=YESit

相关文章: