現在以下のように指定のディレクトリ内にファイルを作成しようとしているのですが、
「touch(): Unable to create file /storage/logs/articles/8.log because No such file or directory」
というエラーが表示されてファイルが作成できません。
php
1 $file = '/storage/logs/articles/' . $id . '.log'; 2 if (!file_exists($file)){ 3 touch($file); 4 }
/storage/logs/articles/のディレクトリは存在しています。
なぜファイルが作成できないのでしょうか?
どこが間違っているのか教えていただきたいです。
よろしくお願いします。
//////追記//////
php
1$path='/storage/logs/articles/'; 2 $file=$path.$id.'.log'; 3 4 if(file_exists($path) and is_dir($path)){ 5 if(!file_exists($file)){ 6 touch($file); 7 } 8 }
回答4件
あなたの回答
tips
プレビュー