I understand that the topic is jammed to holes , but still. There is a form that sends a .jpeg file using the POST method. You need to save it to the / var / www / html / foto / directory. There is a script that processes and saves the file :
if (isset($_FILES['foto'])) { $uploaddir = '/var/www/html/foto/'; $uploadfile = $uploaddir . basename($_FILES['foto']['name']); //Перемещаем файл из временной папки в указанную if (move_uploaded_file($_FILES['foto']['tmp_name'], $uploadfile)) echo "Файл загружен"; } The directory / foto /, as, in principle, on the directories - / html /, / www /, / var / have 777 access rights, 777 access rights are also on the script /var/www/html/index.php. Mistake:
Warning: move_uploaded_file (/var/www/html/foto/doroga.jpeg): failed to open stream: Permission denied in /var/www/html/logger.php on line 32
Warning: move_uploaded_file (): Unable to move "/ tmp / phpNuynNq 'to'
In line 32: if (move_uploaded_file($_FILES['foto']['tmp_name'], $uploadfile)) .
I understand that the problem is connected with access rights, because the script is working, everything is written perfectly on another server, but I don’t know how to solve the problem! HELP Apache is running as root:
ps auxwwww | grep httpd root 26302 0.0 0.2 419648 16656 ? Ss 12:35 0:00 /usr/sbin/httpd -DFOREGROUND apache 26303 0.0 0.1 421928 11464 ? S 12:35 0:00 /usr/sbin/httpd -DFOREGROUND apache 26304 0.0 0.1 421732 9528 ? S 12:35 0:00 /usr/sbin/httpd -DFOREGROUND apache 26305 0.0 0.1 421732 9528 ? S 12:35 0:00 /usr/sbin/httpd -DFOREGROUND apache 26306 0.0 0.1 421732 9528 ? S 12:35 0:00 /usr/sbin/httpd -DFOREGROUND apache 26307 0.0 0.1 421732 9528 ? S 12:35 0:00 /usr/sbin/httpd -DFOREGROUND apache 26308 0.0 0.1 421732 9528 ? S 12:35 0:00 /usr/sbin/httpd -DFOREGROUND root 26430 0.0 0.0 112728 972 pts/0 S+ 12:44 0:00 grep --color=auto httpd Worth Apache / 2.4.6 (CentOS) PHP / 7.1.19.
sestatuscommandsestatus? - de_frag[root@localhost etc]# sestatus > SELinux status: enabled > SELinuxfs mount: /sys/fs/selinux > SELinux root directory: /etc/selinux > Loaded policy name: targeted > Current mode: enforcing > Mode from config file: enforcing > Policy MLS status: enabledPolicy deny_unknown status: allowed'Max kernel policy version: 31' - Dmitrychcon -t httpd_sys_rw_content_t /var/www/html/foto/ -R- de_fragchcon -t httpd_sys_rw_content_t /var/www/html/foto/ -R- helped! - Dmitriy