[英]PHP Warning: move_uploaded_file(): Unable to move/failed to open stream: Permission denied
i am getting eror mentioned in Title! 我在标题中提到了错误!
But folder i am trying to write to look like this 但是我试图写的文件夹看起来像这样
drwxrw-rw- 2 myuser apache 4096 Oct 25 01:18 files
I Can't understand why. 我不明白为什么。 Here is the code i am writing: 这是我正在编写的代码:
function upload($ext){
$data = array();
if((!empty($_FILES["importList"])) && ($_FILES['importList']['error'] == 0)) {
$filename = basename($_FILES['importList']['name']);
$fileExt = substr($filename, strrpos($filename, '.') + 1);
if (($ext == $fileExt) && ($_FILES["importList"]["size"] < 350000)) {
$newname = $_SERVER['DOCUMENT_ROOT'].'/httpdocs/files/'.$filename;
if (!file_exists($newname)) {
if ((move_uploaded_file($_FILES['importList']['tmp_name'],$newname))) {
$data['results'] = "success";
$data['filepath'] = $newname;
return $data;
} else {
$data['results'] = self::$errorMsg[8001];
return $data;
}
} else {
$data['results'] = self::$errorMsg[8002];
return $data;
}
} else {
$data['results'] = self::$errorMsg[8003];
return $data;
}
} else {
$data['results'] = self::$errorMsg[8004];
return $data;
}
}
}
And from here i am getting this error $errorMsg[8001], Which means it goes all the way to move_upload_file() and fails! 从这里我得到这个错误$ errorMsg [8001],这意味着它一直到move_upload_file()都失败了! Because of the in title mentioned error.. Could anyone help please?? 由于标题中提到的错误。有人可以帮忙吗? What else i need to show to find solution? 我还需要证明什么才能找到解决方案?
As you requested, I post this as an answer, so we can close it: 根据您的要求,我将其发布为答案,因此我们可以将其关闭:
Try to add g+x permission to the folder. 尝试将g + x权限添加到该文件夹。 If your PHP run under apache group, it needs access to enter to the directory 如果您的PHP在apache组下运行,则需要访问该目录才能访问
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.