sys_get_temp_dir() - returns C:\Windows on windows8

牧云@^-^@ 提交于 2019-12-11 02:37:22

问题


On windows8 I got this with php 5.3:

echo sys_get_temp_dir();

output:

C:\Windows

Am I not understand something or it is a bug?

UPD

trying $_ENV:

<?php

var_export($_ENV);

output:

array ( )

Checking upload_tmp_dir:

<?php

echo ini_get('upload_tmp_dir');

output:

C:\Windows\Temp

回答1:


Looking at the PHP source, it will call GetTempPath to determine the temp directory. According to the documentation, the windows directory C:\Windows is the last fallthrough option. You should check under which user profile PHP or its host process is running, maybe the environment needs some fixing.




回答2:


Related to this PHP Bug (only CGI context?).

I have the same problem and the solution is to change the apache configuration to expose the TEMP system environment variable to PHP with this directive in apache configuration file (httpd.conf) :

PassEnv TEMP

Don't forget to activate the env_module, generally uncomment the line "LoadModule env_module modules/mod_env.so".

This solution fixes the result of these PHP functions: sys_get_temp_dir(), tempnam().



来源:https://stackoverflow.com/questions/15360647/sys-get-temp-dir-returns-c-windows-on-windows8

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!