php - fwrite duplicate file when saving to server -
i'm trying save data file using fwrite, problem is creating second file same file name, , data saved second file , not original.
it works under windows localhost, apache 2.4.10, php 5.6 (no second file), not on live server running linux , php 5.4.42.
edit.php
$(document).ready(function() { var pagename = "<?php echo $pagename; ?> "; $('#save').click(function(e) { e.preventdefault(); var content = $('#content').html(); $.ajax({ type: 'post', url: 'includes/readinput.php', data: { content: content, pagename: pagename, } }).done( function(data){ } ); }); }); readinput.php. // receive post variable s "admin/ edit.php" $content = $_post['content']; $pagename = $_post['pagename']; $dirpath= "../content/"; file_put_contents($dirpath.$pagename,$content);
if open file data stored "a" append flag result write @ end of file content:
$file = fopen($filename, 'a'); fwrite($file, 'new content');
then file stored old content , "new content" the end.
Comments
Post a Comment