4

I've got some PHP code that'll create a new file in a set directory:

$target_path = "reports/" . basename($Report_Filename) . ".php";
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { /* code here */ }

It was working perfectly, and has done for some years now, unfortunately we've just moved across to a new server, and I'm now getting this error:

[15-Jul-2010 16:15:48] PHP Warning:  Unknown: open_basedir restriction in effect. File(C:\Windows\TEMP\) is not within the allowed path(s): (C:\inetpub\wwwroot) in Unknown on line 0
[15-Jul-2010 16:15:48] PHP Warning:  File upload error - unable to create a temporary file in Unknown on line 0

Any suggestions on a way around this please? I've checked the permissions on the folders (both the folder I want to upload to, and the Windows TEMP folder) with no joy. I've also tried a couple of tweaks to the php.ini file and in particular the 'open_basedir' line, but no luck with that either.

Thanks

Nick
  • 1,233
  • 13
  • 26
  • 37
  • Have you restarted the web server after making changes to php.ini? – MrWhite Jul 15 '10 at 15:53
  • 1
    have you checked out a phpinfo() page to get the location of the php.ini file that php.exe is actually using? It's very possible there are more than one php.ini file and you are editing the wrong one. – Jonathan Kuhn Jul 15 '10 at 15:55

2 Answers2

6

I've also tried a couple of tweaks to the php.ini file and in particular the 'open_basedir' line, but no luck with that either

Then try again - you did it wrong the first time. Maybe there's another setting elsewhere (e.g. in the webserver config).

Failing that, find out what the open_basedir is and make sure that your upload_tmp_dir in php.ini and the $target_path in your code are both inside it.

C.

symcbean
  • 47,736
  • 6
  • 59
  • 94
  • 1
    You sir, are a star! upload_tmp_dir = "C:\Windows\TEMP\" & open_basedir = "C:\Windows\TEMP\" Worked a treat, thanks so much. – Nick Jul 15 '10 at 15:59
2

It says C:\Windows\TEMP\ is not within the allowed path(s) C:\inetpub\wwwroot So you need to add windows temp folder to open_basedir in php.ini

open_basedir = "C:\inetpub\wwwroot;C:\Windows\TEMP"
lisandro
  • 454
  • 4
  • 12