Can't create temporary file in PHP despite the temp directory exists
i'm making a site that allow the user to upload images. When I make the call to the $_FILE variable in order to move the image to another directory it does nothing. Checking the $_FILE with print_r shows the next information:
(
[pic1] => Array
(
[name] => pic1
[type] =>
[tmp_name] =>
[error] => 6
[size] => 0
)
)
The error 6 seems to be this
UPLOAD_ERR_NO_TMP_DIR
Value: 6; Missing a temporary folder. Introduced in PHP 5.0.3.
But I have a big problem: I can access only to the directory where I put the files, I can't check if the temp directory exists or check the php.ini (The server is from my client, and he can't give me access to other directories)
Fortunately the client is checking these parameters and telling me how they are. So, the temporary directory (upload_tmp_dir) is set to /tmp The /tmp directory actually exists, and have all the permissions:
drwxrwxrwt 34 root root 2832 2014-08-30 00:00 tmp
I've been searching reasons of why it shows the error of "Missing temporary folder" despite it exists, but i can't find a reason or a solution. I leave here a pastebin with the output of ini_get_all()
If you can comment any possible solution i'll be grateful. Thanks.
You may be able to change which directory is "tmp" using this function: http://php.net/manual/en/ini.core.php#ini.upload-tmp-dir
but apparently, you'll have to have this done in the core ini file: http://www.reddit.com/r/PHP/comments/1c87xk/can_i_use_ini_set_to_set_the_value_of_upload_tmp/
Get your client to fix their server's configuration.
There's nothing you can do if they have things broken, and I can't imagine they would fight you on having to fix it. This is not a technical problem... you've already solved the technical part.
Check for open_basedir
. If it is on, the PHP manual states:
If open_basedir is on, then the system default directory must be allowed for an upload to succeed.
Also you could specify a custom directory, and you should check that it isn't already set but not writable. Also stated on that same page is that if the directory specified is not writable, PHP falls back to the system default temporary directory (/tmp).
链接地址: http://www.djcxy.com/p/72800.html上一篇: 更改PHP临时目录