Forum

PHP Error Message: move_uploaded_file(/var/www/html/foto/0000002.jpg): failed to open stream: Permis

Hendro Wicaksono
21 September 2017, 04:14
Hello Hugo, I'm Hendro from Indonesia.
I'm trying to migrate our office infrastructure from apache to hiawatha. But first i have to make sure that existing application is running well in Hiawatha.
One feature of our existing application is image upload. At the first, i failed to upload but fixed after i change MaxRequestSize. But after that i still have one problem. The application show some error:
Message: move_uploaded_file(/var/www/html/foto/0000002.jpg): failed to open stream: Permission denied
and
Message: move_uploaded_file(): Unable to move '/tmp/phptJBJGA' to '/var/www/html/foto/0000002.jpg'

I tried to run the upload feature in apache, it works. But still not in hiawatha.

Do you have any ideas how to fix this? Thank you
Hendro Wicaksono
21 September 2017, 04:40
I 've just realized that image upload feature not run in hiawatha only when the image folder is from NFS sharing. But when i changed the folder to local, it works. What do i need to do so that hiawatha can store image file to folder that shared via NFS.
Hugo Leisink
21 September 2017, 15:32
I'm sure this issue is not Hiawatha related. It's probably an access rights issue. Apache uses mod_php, so PHP scripts run as the same user as the Apache webserver. How do you run PHP scripts with Hiawatha? Do they run as the same user as with Apache? The described error comes from PHP, not Hiawatha. So, the solution must be somewhere in the PHP configuration.
Hendro Wicaksono
21 September 2017, 21:29
You're right hugo. I changed the user running php-fpm to apache, then is works. So now i can now upload the image. But is still one problem. I cannot access the image because of the image folder permission is 600 with only apache user as owner. I think the easiest way to solve this is to change the user running hiawatha to apache. But i didnt get in hiawatha configuration where to change it. Do you have any clues how to change the user running hiawatha? Thank you.
Hugo Leisink
22 September 2017, 08:04
Try permission mode 700.
This topic has been closed.