move_uploaded_file failed to open stream: Permission denied Mac

时间:2017-06-20 12:37:09

标签: php image xampp image-uploading

I want to upload an image. Every time I try to upload the image I recieve the error message found below.

I have already set the permissions to read&write:

Warning: move_uploaded_file(uploads/1000020170620022532img3.png): failed to open stream: Permission denied in /Applications/XAMPP/xamppfiles/htdocs/social-network-master/profile.php on line 41

Warning: move_uploaded_file(): Unable to move '/Applications/XAMPP/xamppfiles/temp/phpYqSkvp' to 'uploads/1000020170620022532img3.png' in /Applications/XAMPP/xamppfiles/htdocs/social-network-master/profile.php on line 41

3 个答案:

答案 0 :(得分:1)

朋友,您只需要创建找到.php文件的目录:

  

上传/

并更改文件夹中的“仅写入”

答案 1 :(得分:0)

请使用以下代码:

move_uploaded_file($_FILES['image']['tmp_name'],'uploads/1000020170620022532img3.png');

如果此代码无效,请检查路径和文件夹权限。

答案 2 :(得分:0)

在终端上尝试

sudo chmod -R 777 upload/

p.s。进入上传目录并直接运行 sudo chmode -R 777