【发布时间】:2014-03-01 12:34:52
【问题描述】:
所以我正在做的是从文件中创建一个带有名称的目录,然后在其中创建一个文本文件。
我的目录结构是这样的,我正在尝试创建文件:
/users/用户名/www/practice
代码是:
$path = /home/用户名/www/practice/
$counter_file = "/home/username/www/practise/counter.txt";
if (file_exists($counter_file)) {
第 2 行:if(!($fp = fopen($counter_file, "r")))
die("无法打开文件");
$counter = (int) fread($fp, 20); fclose($fp); $counter = $counter + 1 ; $path .= $counter mkdir($path , 0777); $path .= content.txt; if (!($fp = fopen($path, "w"))) { die("cannot open the file"); } fwrite($fp, "{$content}"); // content is the variable that has value equal to "file is created" fclose($fp); if(!($fp = fopen($counter_file, "w"))) die("cann't open the file"); fwrite($fp, $counter); fclose($fp); // and store the counter value in the file if(!($fp = fopen("$counter_file", "w"))) die("cann't open the file"); fwrite($fp, $counter); fclose($fp);}
我得到的错误是:
警告:fopen(counter.txt):打开流失败:第 2 行权限被拒绝
无法打开文件
【问题讨论】:
-
试试
/practise/counter.txt。 -
还是同样的错误@putvande
-
你有写权限吗?
-
practise目录有什么权限 -
练习目录的权限为777
标签: php permission-denied