PHP fopen() can't create or update log file (ubuntu) -
i give chmod 777 logs folder doesn't work ... have create log file day day . doesn't create file ... why ?
<?php $server = $_server['remote_addr']; $today = date("d-m-y"); $timest = date("d-m-y h:i:s"); $file = "logs/" . $today . ".txt"; $succ = $_session['logged']; if (file_exists($file)) { $add = file_get_contents($file); $add . = "\nserver : " . $server . "\t username : " . $username . "\t timestamp : " . $timest . "\t success : " . $succ; file_put_contents($file, $add); } else { $fc = fopen($file, "w") or die("unable open file"); $txt = "\nserver : " . $server . "\t username : " . $username . "\t timestamp : " . $timest . "\t success : " . $succ; fwrite($fc, $txt); fclose($fc); } ?>
Comments
Post a Comment