请选择 进入手机版 | 继续访问电脑版

Bacysoft.cn

 找回密码
 邀请注册
查看: 43117|回复: 0

failed to open stream: Permission denied

[复制链接]
发表于 2011-7-25 18:51:42 | 显示全部楼层 |阅读模式
本帖最后由 bacy001 于 2011-7-25 18:52 编辑

问题源码:
  1. <?php
  2.         $content = "Hello World!";
  3.         $file = "Hello.txt";
  4.         $handle = fopen($file,"w");

  5.         if (!is_writable($file))
  6.         {
  7.                 die ("File ".$file." cant write! Please Check first.");
  8.         }
  9.         if (!fwrite($file,$content))
  10.         {
  11.                 die ("Write ".$file." failed!");
  12.         }

  13.         fclose($file);

  14.         die ("Succeed!");

  15. ?>
复制代码
执行以上代码后出现如下错误提示:
  1. Warning: fopen(Hello.txt) [function.fopen]: failed to open stream: Permission denied in /home/www/wwwroot/example/1.php on line 4
  2. File Hello.txt cant write! Please Check first.
复制代码
错误分析: Permission denied 表明是权限错误,一般是服务器目录权限设置问题!

解决办法:
1、登录到服务器,找到本程序所在目录,假设为“example”;
2、执行命令“chown www:www example -R”;
您需要登录后才可以回帖 登录 | 邀请注册

本版积分规则



京ICP备08000958号-1|腾讯云|阿里云|联系方式|Bacysoft.cn

GMT+8, 2024-3-29 17:12 , Processed in 0.016103 second(s), 21 queries , Gzip On.

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表