由于这篇文章的标题几乎是不言自明的,我只是跳到代码:
echo sprintf('%o',fileperms('test.txt'))."<br/>"; fopen("test.txt","w");
有了这个我得到:
100777 fopen(test.txt): Failed to open stream: Permission denied
有任何想法吗 ?
编辑:问题已解决:服务器上存在未正确配置的访问控制列表.
谢谢 !
我认为您可能对文件具有写入/读取权限,但对文件夹没有.在您网站的公共根目录中尝试此操作,看看您是否可以读取或写入该文件.
对于安全模式(http://php.net/manual/en/function.fopen.php),PHP doc说如下:
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可以访问您尝试写入的文件夹.