简体   繁体   中英

move_uploaded_file failed to open stream: Permission denied Mac

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

Friend, You only need only to create the directory where are your .php file is found:

uploads/

And change the Only write in the folder

Please use below code:

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

If this code is not working please check path and folder permission.

try this in terminal

sudo chmod -R 777 upload/

ps got to the upload directory and run sudo chmode -R 777 directly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM