[php-src] Issue #13104: PHP-FPM Upload Issue: Two Temporary Files Created, Second File Not Automatically Deleted (PrivateTmp Setting)

From: Date: Tue, 09 Jan 2024 14:25:37 +0000
Subject: [php-src] Issue #13104: PHP-FPM Upload Issue: Two Temporary Files Created, Second File Not Automatically Deleted (PrivateTmp Setting)
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-246204@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/13104 Author: dugi-x ### Description Environment: 1. Standard cPanel on CentOS v7.9 2. Apache webserver 3. PHP 8.1.26 - 7.4.3 4. PHP-FPM 5. PrivateTmp=true When uploading a file using simple form, two temporary files are created during the file upload process. The first file, /tmp/phpSh29GG, is successfully processed and accessible within PHP. However, the second file, /tmp/20240109-145126-ZZ1BTuW_4FTDUJnhDHTTmQAAAB8-file-ozcr6c, is not accessible from php code, not automatically deleted and leading to disk space consumption over time. I tried setting upload_tmp_dir=/tmp but that didn't really solve the problem. The following code: ```php <pre> <?php if (isset($_FILES['userfile'])) { print_r([ 'FILE' => $_FILES['userfile'], 'sys_get_temp_dir' => sys_get_temp_dir(), 'file_exists' => file_exists($_FILES['userfile']['tmp_name']) ? 'true' : 'false', '/tmp/*' => glob("/tmp/*") ]); } ?> <pre> <form method="post" enctype="multipart/form-data"> <input name="userfile" type="file" /><br /> <input type="submit" value="Send files" /> </form> ``` Resulted in this output: ``` Array ( [FILE] => Array ( [name] => sample1.pdf [type] => application/pdf [tmp_name] => /tmp/phpSh29GG [error] => 0 [size] => 3028 ) [sys_get_temp_dir] => /tmp [file_exists] => true [/tmp/*] => Array ( [0] => /tmp/phpSh29GG ) ) ``` ### PHP Version PHP 8.1.26 - 7.4.3 ### Operating System CentOS v7.9

« previous php.bugs (#246204) next »