我使用的是灯泡7.2.5&还尝试使用php 7.1服务器。我试图创建一个托管网站的文件,但只有1个错误。我无法找到任何解决方案,所以我现在就寻求帮助。我有这样的PHP代码:
$ftp_server = xxxxxxxxxxxxxx; $ftp_username = xxxxxxxxxxxxxxxxxxxxxxx; $ftp_userpass = xxxxxxxxx; $ftp_conn = ftp_connect($ftp_server) or die("Could not connect to $ftp_server"); $login = ftp_login($ftp_conn, $ftp_username, $ftp_userpass); $file = $_FILES['file']['tmp_name']; $file_name = $_FILES['file']['name']; $remote_file = "/uploaded/".$file_name; if (ftp_put($ftp_conn, $remote_file, $file, FTP_ASCII)) { echo "Successfully uploaded $file."; } else { echo "Error uploading $file."; } ftp_close($ftp_conn);
$ftp_server = xxxxxxxxxxxxxx; $ftp_username = xxxxxxxxxxxxxxxxxxxxxxx; $ftp_userpass = xxxxxxxxx; $ftp_conn = ftp_connect($ftp_server) or die("Could not connect to $ftp_server"); $login = ftp_login($ftp_conn, $ftp_username, $ftp_userpass); $file = $_FILES['file']['tmp_name']; $file_name = $_FILES['file']['name']; $remote_file = "/uploaded/".$file_name; if (ftp_put($ftp_conn, $remote_file, $file, FTP_ASCII)) { echo "Successfully uploaded $file."; } else { echo "Error uploading $file."; } ftp_close($ftp_conn);
问题是当我重新加载浏览器并尝试发送任何文件时,显示错误:
警告:ftp_put():无法打开该文件:第10行/opt/lampp/htdocs/host/sent.php中没有此类文件或目录 上传/ opt / lampp / temp / phpgQoyn9时出错。
并且始终显示" / opt / lampp / temp / php [以及一些随机字符] 有人能帮我吗? Pleaseee
答案 0 :(得分:0)
您是目录中的上传图片。然后执行其他过程。
move_uploaded_file($ file,$ remote_file)
if (move_uploaded_file($file, $remote_file) && ftp_put($ftp_conn, $remote_file, $file, FTP_ASCII))
{
echo "Successfully uploaded $file.";
}
else
{
echo "Error uploading $file.";
}
ftp_close($ftp_conn);