Setting "upload_tmp_dir" on a Windows/IIS system running PHP/MySQL

4,578 views
Skip to first unread message

Go Joe Go

unread,
Mar 10, 2009, 8:20:05 AM3/10/09
to Professional PHP Developers
I'm working on site that is PHP/MySQL and running on a Windows/IIS
system. Why? The client insists. Crazy, I know.

Anyway, I am trying to change the file uploads directory setting but
am having no luck overwriting the system setting of: "C:\Windows
\TEMP". That is the diretory that the server returns to me every time
I execute the function "sys_get_temp_dir();" from the scripts.

How can I override this?

I have tried the following:

1) setting the environtmental variable $_ENV['TMPDIR']
$_ENV['TMPDIR'] = 'd:\\inetpub\\webSites\\mysite.com\
\_temp_directory';
where the "_temp_directory" is an empty directory that I created in
the site's root.

2) trying to use ini_set in my script as follows:
ini_set('upload_tmp_dir','d:\\inetpub\\webSites\\mysite.com\
\_temp_directory');

3) by placing the following line directly in the php.ini file in the
file uploads section:
upload_tmp_dir = "d:\inetpub\webSites\mysite.com\_temp_directory"

None of these have been able to get the sys_get_temp_dir(); function
to return anything but "C:\Windows\TEMP".

Does anyone know how to do this?

Thanks,
Joe

Robert Gonzalez

unread,
Mar 10, 2009, 12:33:29 PM3/10/09
to Professi...@googlegroups.com
When you changed the php.ini file, did you:

1) Make sure you were editing the correct php.ini file?
2) Make sure to restart the web server after making the change?

According to the manual you can set this in the ini file.

--
Robert A. Gonzalez

Go Joe Go

unread,
Mar 11, 2009, 7:17:22 AM3/11/09
to Professional PHP Developers
I will ask the client to restart his web server for me. I am not sure
that he did that.

When I run phpinfo(); the file is showing that my temp directory is
the path that I want; however in my scripts when I run this:

<?php echo sys_get_temp_dir(); ?>

it still returns C:\Windows\TEMP

Any ideas?

--------------
Joe



On Mar 10, 12:33 pm, Robert Gonzalez
<robert.anthony.gonza...@gmail.com> wrote:
> When you changed the php.ini file, did you:
> 1) Make sure you were editing the correct php.ini file?
> 2) Make sure to restart the web server after making the change?
>
> According to the manual you can set this in the ini file.
>
> http://us3.php.net/manual/en/ini.core.php#ini.upload-tmp-dir
>

crim...@googlemail.com

unread,
Mar 11, 2009, 8:50:19 AM3/11/09
to Professional PHP Developers

On 11 мар, 13:17, Go Joe Go <Joe.Hoskin...@gmail.com> wrote:

> Any ideas?

I have one. May be, sys_get_temp_dir() and ini_get('upload_tmp_dir')
is not the same thing? :)

Robert Gonzalez

unread,
Mar 11, 2009, 9:38:06 AM3/11/09
to Professi...@googlegroups.com
I think you are right crimaniak. upload_tmp_dir I believe is where PHP saves the temporary file created by an upload. temp_dir is the directory that all temporary files are placed in to when a temporary file is made. I am pretty sure upload_tmp_dir falls back to the system temp directory if the upload_tmp_dir directive is not set.

I will have to look into this more when I get to work.




--
Robert A. Gonzalez
Reply all
Reply to author
Forward
0 new messages