Error uploading image: move_uploaded_file() failed to open stream: Permission denied

Asked 5 months ago, Updated 5 months ago, 14 views

I study PHP using books
The content is to make a shopping cart, and I stumbled when I tried to upload the product image.
When I add an image,

Warning: move_uploaded_file (./gazou/aspara_yama.jpg): failed to open stream: Permission denied in/Applications/XAMPP/xamppfiles/htdocs/product/pro_add_check.php on line 48

This error will result in
I checked the copied code many times, but I couldn't see the wrong part.
Sharing and permission to upload image folders were read/writeable
Please reply.

move_uploaded_file($pro_gazou['tmp_name'], './gazou/'.$pro_gazou['name']);
print'<img src="./gazou/'.$pro_gazou['name'].'>';
print'<br/>';
print'<input type="hidden" name="price" value="'.$pro_price.'">;;

I copied the code like this, but the image is not displayed and an error appears.

php

2022-09-30 11:20

1 Answers

As the error message indicates, the image upload destination directory does not have write permission.On Linux, you can run the following commands:

chmod777 [Path to Image Destination Directory]

For example, to save an image to /var/www/img:

chmod777/var/www/img


2022-09-30 11:20

If you have any answers or tips


© 2023 OneMinuteCode. All rights reserved.