Php can not upload file out of /var/www/html even after disabling Selinux

27 Views Asked by At

OS: RHEL 9 with php 8.3 and httpd. Selinux disabled. Php Application is hosted in /var/www/html/application. Trying to upload file to /home/user/uploads. This error showing:

move_uploaded_file(/home/user/uploads/become_a_student_inline.jpg): Failed to open stream: Permission denied

ls -Z Shows:

$ ls -Z
unconfined_u:object_r:httpd_sys_rw_content_t:s0 uploads

ls -l Shows:

$ ls -l
total 0
drwxrwxr-x. 4 ec2-user apache 35 Mar 27 10:17 uploads
1

There are 1 best solutions below

3
Tahmidur Rahman On

Solved. Could not use home directory. Created uploads in root directory and changed permissions accordingly.