I keep getting this error when attempting to configure the upload directory with Apache 2.2 and PHP 5.3 on CentOS.

In php.ini:

upload_tmp_dir = /var/www/html/mysite/tmp_file_upload/

In httpd.conf:

Directory /var/www/html/mysite/tmp_file_upload/>
    Options  -Indexes
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>
<Directory /var/www/html/mysite/images/>
                Options -Indexes
</Directory>

CentOS directory permissions:


drwxrwxr-x 2 root root 4096 November 11 10:01 images

drwxr-xr-x 2 root root 4096 November 12 04:54 tmp_file_upload

Regardless of what I actually do, I keep getting this error from PHP after i upload the file:

Warning: move_submitted_file(images/robot.digital): unsuccessful to spread out stream: Permission refused in /var/www/html/mysite/process.php online 78

Warning: move_submitted_file(): Not able to maneuver '/tmp/phpsKD2Qm' to 'images/robot.jpg' in /var/www/html/mysite/process.php online 78

As you can tell it never did go ahead and take configuration in the php.ini file concerning the upload file.

What shall we be held doing wrong here?

The reason being images and tmp_file_upload are just writable by root user. For upload to operate we have to make who owns individuals folders just like httpd process owner OR make sure they are globally writable (bad practice).

  1. Check apache process owner: $ps aux | grep httpd. The very first column would be the owner typically it will likely be nobody
  2. Change who owns images and tmp_file_upload to become become nobody or regardless of the owner you present in step one.

    $sudo chown nobody /var/www/html/mysite/images/

    $sudo chown nobody /var/www/html/mysite/tmp_file_upload/

  3. Chmod images and tmp_file_upload how to be writable through the owner, as needed [Appears you have this in position]. Pointed out in @Dmitry Teplyakov answer.

    $ sudo chmod -R 0755 /var/www/html/mysite/images/

    $ sudo chmod -R 0755 /var/www/html/mysite/tmp_file_upload/

  4. For additional particulars why this behavior happend, look into the manual http://php.net/manual/en/ini.core.php#ini.upload-tmp-dir , observe that additionally, it speaking about open_basedir directive.

Change permissions with this folder

# chmod -R 0755 /var/www/html/mysite/images/

Do this

find /var/www/html/mysite/images/ -type f -print0 | xargs -0 chmod -v 664