【发布时间】:2014-05-20 09:34:29
【问题描述】:
我正在为我的项目尝试fopen。它在带有 CodeIgniter PHP 框架的 Ubuntu 上运行。结果是这样的:
A PHP Error was encountered
Severity: Warning
Message: fopen(testFile.txt): failed to open stream: Permission denied
Filename: controllers/home.php
Line Number: 10
can't open file
顺便说一下,这是我在 Controller 上的代码:
public function create_file(){
$ourFileName = 'testFile.txt';
$ourFileHandle = fopen($ourFileName, 'r') or die ("can't open file");
fclose($ourFileHandle);
}
我查看了那个代码,我认为应该有一个打开文件的路径,对吧?如果是,我应该把路径放在哪里?因为,我遵循了本教程中的这段代码:http://www.tizag.com/phpT/filecreate.php。
让我感到困惑的是,没有文件testFile.txt 我想创建它,但是如何授予创建它的权限。因为终端会说No such file or directory for the file。我该怎么办?
我还尝试在www 目录上运行chmod。但是,它仍然没有工作。
希望有人帮我解决这个问题。谢谢...
【问题讨论】:
-
您是否尝试使用 sudo 为该文件提供 chmod 777 或 755?
标签: php codeigniter ubuntu