Q&A
なぜこのような事が起こるか教えて頂けたらと。
ubuntu20.4のApache2を使用しております。
ディレクトリ構成
Directory
1root 2├dir1 3 ├file_put.php 4 ├time.txt rw-r--rw- 5├dir2 6 ├test.php
動くソース
file_put.php
1 2 $mes = "今何時?"; 3 f_put($mes); 4 5 function f_put($mes){ 6 $path = "./time.txt"; 7 file_put_contents( $path, $mes. " : " .date( "Y/m/d H:i:s" ). PHP_EOL, FILE_APPEND ); 8 }
Permission deniedを吐くソース
test.php
1 require_once('../dir1/file_put.php'); 2 $e = "今何時?"; 3 f_put($e);
エラー
Warning: file_put_contents(./time.txt): Failed to open stream: Permission denied in /dir1/test.php on line
補足
test.phpにて実行する時は file_put.php から
$mes = "今何時?";
f_put($mes);
は抜いております
回答3件
下記のような回答は推奨されていません。
このような回答には修正を依頼しましょう。