Can't upload images to destinated dir in localhost by php

I code a php file in localhost which upload images to my destinated dir.
After the clicks everythings work well, but I didn’t find my uploaded images in my /srv/http/uploads dir.
I then upload my php to my host server online then test it. It works. My files are uploaded to my destinated dir. So I know it’s about my localhost server.

I read an article in Stack Overflow and then I change my httpd.conf and php.ini files to this:

httpd.conf

<Directory /srv/http/tmp/>
   Options - Indexes
   AllowOverride none
   Require all granted
 </Directory>

<Directory /srv/http/tmp/>
   Options - Indexes
</Directory> 

php.ini

file_uploads = On
upload_tmp_dir = /srv/http/tmp/
upload_max_filesize = 500M

I also change the permission of my srv/http/ dir to myself use chown command. Still no use.
How can I get this work?

the command ??? at you to add “can write” in /srv/http/uploads/(only this folder) for “http” user

return or check ls -ld /srv/http/uploads

You must change the folder’s read/write/execute permission to the user that is running the server, not yourself.

It works after I change the read/write/execute permission

sudo chown 777 http/tmp/
sudo chown 777 http/uploads/

Thanks!

sudo chown -hR user:user /srv/

I change owner but not the permission for read/write/execute. I then run command to change the permission. It works.
Thanks :slight_smile:

You should read and understand the permission part of this fine post [Tutorial] Understanding and working with UNIX filesystems and permissions

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.