Vitaly Dyatlov
Vitaly Dyatlov

Reputation: 1872

sys_get_temp_dir() - returns C:\Windows on windows8

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

Upvotes: 2

Views: 3425

Answers (2)

Jean Louis
Jean Louis

Reputation: 11

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().

Upvotes: 1

Marcus Ilgner
Marcus Ilgner

Reputation: 7211

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.

Upvotes: 2

Related Questions