具有777权限的文件上的fopen权限被拒绝 [英] fopen Permission denied on a file with 777 permissions

查看:260
本文介绍了具有777权限的文件上的fopen权限被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于这篇文章的标题几乎是不言自明的,所以我将跳转到代码:

Since the title of this post is pretty much self-explanatory, I'll just jump to the code :

echo sprintf('%o', fileperms('test.txt'))."<br/>";

fopen("test.txt", "w");

有了这个我得到:

100777
fopen(test.txt): failed to open stream: Permission denied

有什么想法吗?

问题解决:服务器上存在访问控制列表,配置不正确.

Edit : Problem solved : there were access control lists on the server that were not configured correctly.

谢谢!

推荐答案

我认为您可能对文件具有写/读权限,但对文件夹没有读/写权限.在您网站的公共根目录中尝试此操作,看看是否可以读取或写入文件.

I think its possible that you have write/read permissions on the file but not on the folder. Try this in the public root of your website and see if you can read or write the file.

对于安全模式( http://php.net/manual/en/function. fopen.php ),则php doc表示以下内容:

For safe mode (http://php.net/manual/en/function.fopen.php), php doc's say the following:

注意:启用安全模式后,PHP会检查目录中是否存在 该脚本正在运行的脚本具有与该脚本相同的UID(所有者) 正在执行.

Note: When safe mode is enabled, PHP checks whether the directory in which the script is operating has the same UID (owner) as the script that is being executed.

最后,您还需要确保php可以访问您要写入的文件夹.

Last you also need to be sure that php has access to the folder you are trying to write to.

这篇关于具有777权限的文件上的fopen权限被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆