所以我在做的是用文件中的名字创建一个目录,然后在其中创建一个文本文件。无法创建文件usind PHP?
我的目录结构是这样的,我想创建该文件:
/用户/名/ WWW /实践
而且代码:
$ path =/home/username/www/practice/
$ counter_file =“/home/username/www/practise/counter.txt”;
如果(file_exists($ counter_file)){
线2:(!($ FP =的fopen($ counter_file, “R”)))如果
模具(“不能打开文件“);
$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
无法打开文件
尝试'/ practice/counter.txt'。 – putvande
仍然是一样的错误@putvande – Deepu
你有写权限吗? –