Is there any existing php code that will allow me to edit and save files from the browser?
Ex: a text area on the page site.com/edit.php would save to a specified file? I want to be able to edit files on the fly.
I am hosting the site on XAMPP and cant seem to get FTP working so this would be a big use if I need to edit a file and cant get access to the hosting computer.
This is the closest I have found to what I need, however cant seem to get it to work (the goal is to change ‘change.php’):
<?php
if ($changefile) {
$slash = stripslashes($_POST['filetest']);
$filetochange = "change.php";
$filetochangeOpen = fopen($filetochange,"w") or die ("Error editing.");
fputs($filetochangeOpen,$slash);
fclose($filetochangeOpen) or die ("Error Closing File!");
}
?>
<form method=post action="">
<textarea rows="40" cols="60" name="filetest">
<?
// Implode CSS
$filetochange = "change.php";
print (implode("",file($filetochange)));
?>
</textarea><br />
<br />
<input type="submit" value="Change File" name="changefile">
</form>
www-datahas to have write permission for the files or it won’t work. Be careful with this. Either limit access to your own IPs (as you said) or put in a password protected folder with SSL.