将上传的文件移动到远程服务器上 [英] Moving an uploaded file onto a remote server

查看:114
本文介绍了将上传的文件移动到远程服务器上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



move_uploaded_file($ tmp_name,uploads / $ code1 / $ code)

我试图将上传的文件移动到远程服务器上, 。$ fileex);

  $ ftp_server =IP; 
$ ftp_user_name =用户名;
$ ftp_user_pass =密码;
$ file = $ tmp_name;
$ remote_file =/ public_html / test / uploads /;

//设置基本连接
$ conn_id = ftp_connect($ ftp_server);

//使用用户名和密码登录
$ login_result = ftp_login($ conn_id,$ ftp_user_name,$ ftp_user_pass);
$ b $ //上传文件
if(ftp_put($ conn_id,$ remote_file,$ file,FTP_ASCII)){
echo成功上传$ file \\\
;
} else {
echo上传$ file \\\
时出现问题;
}

//关闭连接
ftp_close($ conn_id);

我得到这个erorr;

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

解决方案

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


I am trying to move an uploaded file onto a remote server, this isn't working;

move_uploaded_file($tmp_name, "uploads/$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);

I get this erorr;

Warning: ftp_put() [function.ftp-put]: Can't open that file: Is a directory in /home/file/public_html/uploaded.php on line 52

解决方案

Your $remote_file variable is pointing to a directory when it should point to a file. Try changing $remote_file to $remote_file = "/public_html/test/uploads/".$file;

这篇关于将上传的文件移动到远程服务器上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆