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

2
  • Have you restarted the web server after making changes to php.ini? Commented Jul 15, 2010 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. Commented Jul 15, 2010 at 15:55

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

You sir, are a star! upload_tmp_dir = "C:\Windows\TEMP\" & open_basedir = "C:\Windows\TEMP\" Worked a treat, thanks so much.
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"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.