Search code examples
phplinuxapacheserverfedora-25

I keep getting UPLOAD_ERR_NO_TMP_DIR while uploading file using PHP


I am trying to upload a file on my Apache server on Fedora 25 (32 bit) using PHP 7.0.15.

I am getting an UPLOAD_ERR_NO_TMP_DIR error, even though I have set appropriate (and even more than I should have, but I am working locally at the moment) permissions for the upload directories and i have changed the owner of the directory to apache.

I am trying to upload a .docx file 6kB large, my upload_tmp_dir in php.ini is set to /home/temporary.

ls -l returns the following code:

drwxrwxrwx.  2 apache root           4096 Feb 11 20:14 temporary

sys_get_tmp_dir() returns the correct path: /home/temporary

But I still get error 6

debug outputArray
(
[userfile] => Array
    (
        [name] => rus.docx
        [type] => 
        [tmp_name] => 
        [error] => 6
        [size] => 0
    )
)

What can cause this problem?


Solution

  • Put the temporary directory under /var/www or /var/www/html.

    Apart from this action you also need to grant Apache the rewrite permissions with semanage.