Skip to main content
Source Link
Dis_Pro
  • 224
  • 2
  • 14

Cannot write a file

I need to write file by pushing retrieved data in to text file. But the file not write. This is the relevant code section. This code section contains within function in controller.

            $filename = "form_ipn.log";
            $fh = fopen($filename, "a") or die("Could not open log file.");
            fwrite($fh, date("d-m-Y, H:i")." - $name;\n") or die("Could not write file!");
            fclose($fh);

I have created a file inside a controller->adminhtmlfolder. Is there any problem with this folder regarding writing privileges? Or is there any problem on my code?