PHP directory error - open_basedir restriction in effect
Solution 1
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.
Solution 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"
Related videos on Youtube
Nick
Updated on May 13, 2020Comments
-
Nick almost 4 years
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
-
MrWhite almost 14 yearsHave you restarted the web server after making changes to php.ini?
-
Jonathan Kuhn almost 14 yearshave 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.
-
-
Nick almost 14 yearsYou sir, are a star! upload_tmp_dir = "C:\Windows\TEMP\" & open_basedir = "C:\Windows\TEMP\" Worked a treat, thanks so much.