dongpu2694 2016-03-08 11:01
浏览 114

PHP不将文本写入txt文件Windows Server 2012 R2

I am trying to add text to txt file via php in new production server that is not inserting if the same am trying on my local machine that happens and i have given all permission to the folder in server though that is not saving this sound funny i tried all possible ways that google says still not working

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

output error with in the directory

   PHP Warning:  fopen(newfile.txt): failed to open stream: Permission denied in C:\Inetpub\vhosts\test.in\httpdocs\Test.php on line 2

error for different drive

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
  • 写回答

1条回答 默认 最新

  • doujiaozhan2413 2016-03-08 11:16
    关注

    There are a number of reasons why your PHP script might not be able to write to the filesystem. The most common one is a permissions issue: the user that your Web server runs as does not have permission to write to the directory in question.

    Another reason why you might not be able to write to files is that some service providers in my experience disable file I/O functions in the php.ini file using the disable_functions directive. You would have to get the administrator of the server to change this for you.

    评论

报告相同问题?

悬赏问题

  • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
  • ¥20 关于URL获取的参数,无法执行二选一查询
  • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
  • ¥15 marlin编译错误,如何解决?
  • ¥15 有偿四位数,节约算法和扫描算法
  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集