file_put_contents - failed to open stream: Permission denied(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 - 无法打开流:权限被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:file_put_contents - 无法打开流:权限被拒绝
基础教程推荐
- PHP 类:全局变量作为类中的属性 2021-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- 如何替换eregi() 2022-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
