首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >plesk PHP在将文本写入txt文件时出现错误

plesk PHP在将文本写入txt文件时出现错误
EN

Stack Overflow用户
提问于 2016-03-08 21:40:01
回答 2查看 372关注 0票数 1

我的VPS 2012 R2配置了一个plesk和一个域名,当我尝试在txt文件中创建和写入文本时出现错误,我尝试了所有可能的方法来解决它无法解决的问题

我的PHP

代码语言:javascript
复制
  <?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);
?>

错误:

代码语言:javascript
复制
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
EN

回答 2

Stack Overflow用户

发布于 2016-03-09 23:00:44

除了open_basedir之外,您的PHP脚本在特定的系统用户下执行,该用户仅在的C:/Inetpub/vhosts/test.in中具有权限

同时在“托管设置”中检查“附加写入/修改权限”:

票数 2
EN

Stack Overflow用户

发布于 2016-03-08 21:43:09

您已经启用了open_basedir,这限制了允许其读写文件的范围(以防止可能读写文件系统上的任何文件的潜在攻击或bug)。删除设置或写入配置的基本目录中的文件。

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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35868983

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档