Results 1 to 4 of 4

Thread: PHP Warning: File upload error - unable to create a temporary file in Unknown

  1. #1
    Join Date
    Mar 2014
    Posts
    8

    PHP Warning: File upload error - unable to create a temporary file in Unknown

    This is a problem that keep recurring.


    We have servers with PHP FPM and for some strange reason this problem keep happening:


    Got error 'PHP message: PHP Notice: Unknown: file created in the system's temporary directory in Unknown on line 0\nPHP message: PHP Warning: File upload error - unable
    to create a temporary file in Unknown on line 0\n'.


    Our user php conf looks like the following when it first happened:


    [DAUSER]
    user = $pool
    group = $pool
    listen = /usr/local/php72/sockets/$pool.sock
    listen.owner = $pool
    listen.group = apache
    listen.mode = 660
    pm = ondemand
    pm.max_children = 100
    pm.process_idle_timeout = 20
    php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f DAUSER@loyalbasterds.nl
    php_admin_value[session.save_path] = /home/DAUSER/tmp
    php_admin_value[open_basedir] = /home/DAUSER/:/tmp/:/var/tmp/:/usr/local/php72/lib/:/usr/local/php54/lib/:/usr/local/php55/lib/:/usr/local/php56/lib/:/usr/local/php70/lib/:/usr/local/php71/lib/:/usr/local/php72/lib/:/usr/local/lib/php/
    php_admin_value[mail.log] = /home/DAUSER/.php/php-mail.log
    security.limit_extensions = .php .php52 .php53 .php54 .php55 .php56 .php60 .php70 .php71 .inc .php72


    It was thought that the actual fix was, by adding the tmp variables in the user php fpm conf:

    env[TMP] = /tmp
    env[TMPDIR] = /tmp
    env[TEMP] = /tmp

    Restart php-fpm, the problem seemed fix at first. But, our websites still cannot upload files.

    The temporary fix seems to restart php fpm. But, after a while the problem happens again.
    And the conf still has the /tmp variables.

    We added, in all the php.ini we could find, the upload_tmp_dir = /tmp, and that alse was a temporary fix.

    EDIT:

    ----- -----

    This has happened on multiple shared and dedicated servers, with multiple websites.


    I did a test on our test server:
    `sys_get_temp_dir()`: gives the

    `/tmp`

    `ini_get('upload_tmp_dir')`: gives no value:

    `string(0) ""`

    But my test files uploaded fine

    Test code used from:https://www.w3schools.com/php/php_file_upload.asp


    `PrivateTmp=true` is set to true on the PHP FPM instance. This should not have any effect, because we are giving /tmp as the specified dir...?


    - CentOS Linux release 7.5.1804 (C
    - DirectAdmin server
    - PHP-FPM
    - PHP 7.2.10 (FPM)

    ----- -----

    Is there any way how to permanently fix this issue? The keeps happening on multiple server of our customers, and we can't just keep restarting PHP-FPM
    Last edited by dhm; 11-06-2018 at 01:54 AM. Reason: added further info

  2. #2
    Join Date
    Apr 2005
    Location
    GMT +7.00
    Posts
    12,385
    Hello,

    Do you have suhosin with suhosin_php_uploadscan enabled?

    Code:
    grep suhosin /usr/local/directadmin/custombuild/options.conf
    Try and rebuild:

    Code:
    ./build update
    ./build php
    ./build clamav
    ./build suhosin
    and check, post results of

    Code:
    grep ^PrivateTmp --color /etc/systemd/system/*.service

  3. #3
    Join Date
    Mar 2014
    Posts
    8
    Here is my settings:

    grep suhosin /usr/local/directadmin/custombuild/options.conf
    suhosin=no
    suhosin_php_uploadscan=no

    I've updated PHP, no clamav/suhosin

    ./build update
    ./build php


    ----

    grep ^PrivateTmp --color /etc/systemd/system/*.service
    /etc/systemd/system/exim.service:PrivateTmp=true
    /etc/systemd/system/httpd.service:PrivateTmp=true
    /etc/systemd/system/mariadb.service:PrivateTmp=true
    /etc/systemd/system/mysqld.service:PrivateTmp=true
    /etc/systemd/system/named.service:PrivateTmp=true
    /etc/systemd/system/php-fpm72.service:PrivateTmp=true

  4. #4
    Join Date
    Apr 2009
    Posts
    2,169
    Perhaps it is a bug relateted to this new feature/behaviour: https://www.directadmin.com/features.php?id=2131

    Personally I have disabled the new feature/behavior, so that it work the same way as before DirectAdmin 1.53.1. To disable and see if that solves the problem, then do what it says at the bottom of the feature link:

    Code:
    At any time, you can disable the feature by adding:
    php_home_tmp_session_save_path=0
    
    to the directadmin.conf, restart DA, and also issue a config rewrite:
    cd /usr/local/directadmin/custombuild
    ./build rewrite_confs

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •