file_put_contents权限被拒绝 [英] file_put_contents permission denied

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

问题描述

我试图写一个查询到一个文件进行调试。该文件位于 database / execute.php 中。我要写入的文件是 database / queries.php



我试图使用 file_put_contents('queries.txt',$ query)



但是我得到了


file_put_contents(queries.txt)[function.file-put-contents]:
无法打开流:权限
被拒绝

我将 queries.txt 文件chmod'd改为777,问题是什么?请尝试调整目录权限。



从终端运行,运行

code> chmod 777 database (从包含数据库文件夹的目录)

apache和没有人可以访问这个目录if它正确chmodd'ed

另一件事是回声getcwd()。这将显示当前目录,如果这不是'/something.../database/',那么你需要改变'query.txt'到你的服务器的完整路径。


I am trying to write a query to a file for debugging. The file is in database/execute.php. The file I want to write to is database/queries.php.

I am trying to use file_put_contents('queries.txt', $query)

But I am getting

file_put_contents(queries.txt) [function.file-put-contents]: failed to open stream: Permission denied

I have the queries.txt file chmod'd to 777, what could the issue be?

解决方案

Try adjusting the directory permissions.

from a terminal, run chmod 777 database (from the directory that contains the database folder)

apache and nobody will have access to this directory if it is chmodd'ed correctly.

The other thing to do is echo "getcwd()". This will show you the current directory, and if this isn't '/something.../database/' then you'll need to change 'query.txt' to the full path for your server.

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

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