0

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

My index.php in the public folder:

<?php
$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));
fclose($fh);
require_once 'Framework/SiteHandler.php';

Zend_Controller_Front::getInstance()
    ->setControllerDirectory('../application/controllers')
    ->throwExceptions(false)
    ->dispatch();
?>

How should i fix that?

Vic Seedoubleyew
  • 9,888
  • 6
  • 55
  • 76
user3665428
  • 7
  • 1
  • 5
  • Do you have the right permissions? Does the file exist? – DankMemes May 24 '14 at 19:15
  • The file exists and yes i have the right permissions. – user3665428 May 24 '14 at 19:19
  • Thx it worked but is there a way to get the old Website back? I mean before i used Zend, i had normal acces to my site and now I just get a kind of 'code'. I also have a home.php but idk how to use it^^. Sry im new in this – user3665428 May 24 '14 at 19:25
  • Whoops I overlooked this, I'm sorry. When you specify a mode to fopen you need a real mode and _append_ t to use text translation mode. In other words, you can't just use t. You need something like `rt` or `wt` or `at`. See here: http://www.php.net/manual/en/function.fopen.php – DankMemes May 24 '14 at 19:25
  • Your use of a relative path in fopen is wrong too. See here for explanations and solutions : http://stackoverflow.com/questions/36577020/failed-to-open-stream-no-such-file-or-directory – Vic Seedoubleyew Sep 10 '16 at 10:57

2 Answers2

0

Use fopen($File, 'a') instead of fopen($File, 't').

René Roth
  • 1,979
  • 1
  • 18
  • 25
0

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: http://www.php.net/manual/en/function.fopen.php

DankMemes
  • 2,085
  • 2
  • 21
  • 30
  • Well, thx. I used rt now. But is there a way to get my 'old' website back, like before i used Zend Framework? When I acces ma site i get this imgur.com/vTxwI1H – user3665428 May 24 '14 at 20:02
  • Start a new question. Questions aren't meant for answering multiple things. Also use `http://` to linkify links, like this: http://imgur.com/vTxwI1H – DankMemes May 25 '14 at 13:44
  • Use of a relative path in fopen is wrong too. See here for explanations and solutions : http://stackoverflow.com/questions/36577020/failed-to-open-stream-no-such-file-or-directory – Vic Seedoubleyew Sep 10 '16 at 10:57