php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74189 PHP Notice: Unknown: file created in the system's temporary directory in Unknow
Submitted: 2017-03-01 10:03 UTC Modified: 2017-03-01 12:57 UTC
From: costinel dot manole at gmail dot com Assigned:
Status: Closed Package: *General Issues
PHP Version: 7.1.2 OS: Centos 7
Private report: No CVE-ID: None
 [2017-03-01 10:03 UTC] costinel dot manole at gmail dot com
Description:
------------
Since installing php 7.1.2 I got my errror log full of this notice 
"PHP Notice:  Unknown: file created in the system's temporary directory in Unknown on line 0"


It apears every time I upload a file.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-03-01 10:29 UTC] spam2 at rhsoft dot net
what about just not using /tmp for file uploads?

something like: upload_tmp_dir = "/var/www/uploadtemp"

or way better a own "upload_tmp_dir" for every virtual host so that one can't steel temp file from other users?
 [2017-03-01 10:41 UTC] costinel dot manole at gmail dot com
I have already tried.
upload_tmp_dir = "/tmp/httpd/upload"
sys_temp_dir = "/tmp/httpd"

Anyway, I have no problems with file uploading and I don't need to change any config. I just wanted to report that the notice is not displaying ok ("Unknown on line 0"). Also I would like to turn off this notice, if it's possible. I upload files every hour and I don't want any notice to inform me that I have sucessfuly uploaded files.
 [2017-03-01 10:48 UTC] spam2 at rhsoft dot net
well i am not a php-developer but the point is *not* using /tmp which is shared between applications and servies at all and so "what about just not using /tmp for file uploads" answering with "i have tried /tmp/somesubdir" is strange

"Unknown on line 0" in that case is because it's no line of PHP code which triggers that

so lwoer error reporting or just use sane uplod directories and don't open /tmp at all for a webserver - in other words forbid it by eclude /tmp from open_basedir and anything else
 [2017-03-01 11:30 UTC] costinel dot manole at gmail dot com
On my server "/var/www/uploadtemp" is not shared by multiple apps.

Anyway I have changed to 
upload_tmp_dir = "/var/www/upload"
sys_temp_dir = "/var/www/upload"

Same result.

I have eliminated all the PHP code from file. The PHP notice is generated with pure HTML Code

<form action="test_upload.php" method="post" enctype="multipart/form-data">
<input name="userfile[]" type="file" id="userfile" maxlength=""  multiple />
<input type="submit" name="submit" value="Send File"></td>
</form>

If I attach 3 files I get 3 notices in error_log
 [2017-03-01 11:39 UTC] spam2 at rhsoft dot net
> Anyway I have changed to 
> upload_tmp_dir = "/var/www/upload"
> sys_temp_dir = "/var/www/upload"
>
> Same result

what do you expect?
"file created in the system's temporary directory"

and to solve it you set "upload_tmp_dir" and "sys_temp_dir" *again* to the same value which is the problem

common sense:
upload_tmp_dir = "/var/www/upload"
sys_temp_dir = "/tmp"
 [2017-03-01 11:44 UTC] nikic@php.net
The notice occurs if creating a temporary file in the specified directory failed and PHP has to fall back to the system temporary directory. Can you please check whether the directory you specified by upload_tmp_dir is actually writable by the user PHP runs under?
 [2017-03-01 12:16 UTC] costinel dot manole at gmail dot com
I can copy or delete files from php in upload_tmp_dir.
But $_FILES['userfile']['tmp_name'] returns my sys_temp_dir
I have tried all combinations of folders including:
upload_tmp_dir = "/var/www/upload"
sys_temp_dir = "/tmp"
 [2017-03-01 12:21 UTC] spam2 at rhsoft dot net
just check the permissions of every parent folder and make sure nothing overrides "upload_tmp_dir" - verify that with phpinfo()
 [2017-03-01 12:57 UTC] costinel dot manole at gmail dot com
-Summary: weird notice on file upload +Summary: PHP Notice: Unknown: file created in the system's temporary directory in Unknow -Status: Open +Status: Closed
 [2017-03-01 12:57 UTC] costinel dot manole at gmail dot com
I found the problem. upload_tmp_dir was overridden for a specific site in vhosts.conf, and that folder was deleted recently.

Thank you for help, ans sorry for losing your time. I still consider that the mesage of that notice can be improved. (eg: 'Can not write to upload_tmp_dir')
 [2019-02-28 16:02 UTC] absfregs at gmail dot com
to solve is simple, only coment the upload_tmp_dir with ";" in the file "php.ini"

PHP 7.3.1
 [2019-02-28 16:54 UTC] spam2 at rhsoft dot net
besdies that bugreport is 3 years old you can comment and write what you want in php.ini when a vhost override points to a non-existing folder
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Oct 25 06:03:33 2021 UTC