PHP directory error - open_basedir restriction in effect

本秂侑毒 提交于 2021-01-23 11:06:34

问题


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


回答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.




回答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"


来源:https://stackoverflow.com/questions/3257090/php-directory-error-open-basedir-restriction-in-effect

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!