2016-03-08 62 views
1

我的VPS 2012 R2我有一个plesk配置和一个域当我试图创建和写入文本在txt文件,给了我错误我试过所有可能的方法来解决它我不能做plesk PHP上写文本到txt文件给出错误

我的PHP

<?php 
$myfile = fopen("E:\Log\newfile.txt", "w") or die("Unable to open file! " . var_export(error_get_last(), true)); 
$txt = "Mickey Mouse\n"; 
fwrite($myfile, $txt); 
$txt = "Minnie Mouse\n"; 
fwrite($myfile, $txt); 
fclose($myfile); 
?> 

错误:

PHP Warning: fopen(): open_basedir restriction in effect. File(E:\Log 
ewfile.txt) is not within the allowed path(s): (C:/Inetpub/vhosts/test.in\;C:\Windows\Temp\) in C:\Inetpub\vhosts\test.in\httpdocs\Test.php on line 2 
PHP Warning: fopen(E:\Log 
ewfile.txt): failed to open stream: Operation not permitted in C:\Inetpub\vhosts\test.in\httpdocs\Test.php on line 2 
+0

该文件夹处于完全许可仍然给我相同的错误 – Shaik

+0

错误信息的哪部分你不明白? – symcbean

回答

1

你有open_basedir开启这限制PHP在哪里允许读取和写入文件(以prote克服可能读取或写入文件系统上的任何文件的潜在攻击或错误)。删除设置或写入配置的基本目录中的文件。

http://php.net/manual/en/ini.core.php#ini.open-basedir

+0

我有一种方法可以添加一个新的目录,即使在不允许的目录中也是如此 – Shaik

+0

你不能在'open_basedir'设置之外读或写,这就是整个设置的重点:P你可以添加'E:/ Logs'到你的'open_basedir'。 – Halcyon

1

旁边的open_basedir,你的PHP脚本在其下有权限只有内部C:/Inetpub/vhosts/test.in

特殊的系统用户执行还要检查这个“附加写入/修改权限”中的“虚拟主机设置”: enter image description here