【发布时间】:2013-07-14 21:13:06
【问题描述】:
我正在尝试使用以下方法将文件上传到 FTP:
$ftp_server="***********";
$ftp_user_name="*********";
$ftp_user_pass="************";
$file = $path;//tobe uploaded
$remote_file = "/htdocs/site2/telemessages/en/".$_SESSION['dir'];
// 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)
但是,我收到以下错误消息:
提前致谢。
【问题讨论】:
-
看起来您正在尝试上传文件但将其称为目录。确保
$_SESSION['dir']包含远程服务器上可接受的有效文件名 -
$file 和 $remote_file 的值是什么
-
感谢反馈 $_SESSION =birthdays/Child/ 因此 $remote_file = /htdocs/site2/telemessages/en/birthdays/Child/ -$file = 1794 - 岳父生日快乐。 mp3 $file 来自具有输入类型表单的表单,但我理解由于安全原因,您实际上不能存储完整路径!?谢谢