file_put_contents - 无法打开流:权限被拒绝 [英] file_put_contents - failed to open stream: Permission denied

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

问题描述

我正在尝试将查询写入文件以进行调试.该文件位于 database/execute.php 中.我要写入的文件是 database/queries.php.

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.

我正在尝试使用 file_put_contents('queries.txt', $query)

但是我得到了

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

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

我将 queries.txt 文件修改为 777,可能是什么问题?

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

推荐答案

尝试调整目录权限.

从终端运行 chmod 777 database(从包含数据库文件夹的目录)

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

如果 chmodd 正确,apache 和任何人都无法访问此目录.

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

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

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天全站免登陆