php - Cannot edit the file -
<?php $filename = "changelog.txt"; $newdata = $_post['newd']; if ($newdata != '') { $fw = fopen($filename, 'w') or die('could not open file! error 1'); $fb = fwrite($fw,stripslashes($newdata)) or die('could not write file'); fclose($fw); } $fh = fopen($filename, "r") or die("could not open file!"); $data = fread($fh, filesize($filename)) or die("could not read file! error 2"); fclose($fh); echo "<form action='$_server[php_self]' method= 'post' > <textarea name='newd' cols='100%' rows='50'> $data </textarea> <input type='submit' value='change'> </form>"; ?>
so found code google add file editor, shows file editor, when add new line , click change, says "could not open file"
. me out?
this editor can open file reading , fails when try open writing.
it's not php issue. it's filesystem prevents writing access. there several solutions: give directory 777 rights, let webuser own directory or let join group has permissions, ...
navigate log directory , try sudo chmod -r 777 .
i presume have linux.
Comments
Post a Comment