user3665428 user3665428 - 5 months ago 23
HTML Question

PHP - fopen log_post.txt failed to open stream: no such file or directory

Warning: fopen(log_post.txt): failed to open stream: No such file or directory in C:\xampp\htdocs\MyApp\public\index.php on line 3
can't open file

in the public folder:

$File = "log_post.txt";
$fh = fopen($File, 't') or die("can't open file");
fwrite($fh, "\n");
#$headers = apache_request_headers();
#foreach ($headers as $h => $v)
# fwrite($fh, "$h: $v\n");
#fwrite($fh, print_r($HTTP_RAW_POST_DATA,1));
require_once 'Framework/SiteHandler.php';


How should i fix that?


The function fopen has no mode t. You need to specify a mode such as w, a, r, etc., and then append t to use line ending translation mode. Use something like this:

fopen($File, "rt");

Where you can change rt to any valid php mode and t at the end, such as at, wt, r+t, etc.

See here for info: