我正在为我的博客构建管理员后端,并且尝试使用下面的代码上传文件,但是却收到500 Internal Server Error nginx / 1.13.2。我检查了nginx_error日志,它显示ailed (13: Permission denied), client: 127.0.0.1, server: , request: "POST
。我知道这与错误日志中的权限有关,但是我如何允许该权限。我已经搜索过,找不到适合我的好答案。谢谢大家以下是我的php代码
$errors= array();
$file_name = $_FILES['image']['name'];
$file_size =$_FILES['image']['size'];
$file_tmp =$_FILES['image']['tmp_name'];
$file_type=$_FILES['image']['type'];
$file_ext=strtolower(end(explode('.',$_FILES['image']['name'])));
$expensions= array("jpeg","jpg","png");
if(in_array($file_ext,$expensions)=== false){
$errors[]="extension not allowed, please choose a JPEG or PNG file.";
}
if($file_size > 2097152){
$errors[]='File size must be excately 2 MB';
}
if(empty($errors)==true){
move_uploaded_file($file_tmp,"images/".$file_name);
echo "Success";
}else{
print_r($errors);
}
}
感谢您的时间和帮助:)