PHP目录错误 - open_basedir限制生效

时间:2010-07-15 15:25:58

标签: php file upload open-basedir

我有一些PHP代码会在set目录中创建一个新文件:

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

它工作得很好,已经做了好几年了,不幸的是我们刚刚搬到新的服务器上,现在我收到了这个错误:

[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

有关这方面的任何建议吗?我已经检查了文件夹的权限(我要上传到的文件夹和Windows TEMP文件夹)没有任何乐趣。我也尝试过对php.ini文件进行一些调整,特别是'open_basedir'行,但是没有运气。

由于

2 个答案:

答案 0 :(得分:3)

  

我也尝试过对php.ini文件进行一些调整,特别是'open_basedir'行,但是没有运气

然后再试一次 - 你第一次做错了。也许在其他地方还有其他设置(例如在网络服务器配置中)。

如果失败了,请找出open_basedir是什么,并确保php.ini中的upload_tmp_dir和代码中的$ target_path都在其中。

下进行。

答案 1 :(得分:2)

它表示C:\ Windows \ TEMP \不在允许的路径内C:\ inetpub \ wwwroot 因此,您需要在php.ini中将Windows临时文件夹添加到open_basedir

open_basedir = "C:\inetpub\wwwroot;C:\Windows\TEMP"
相关问题