<?php
// configuration
$url = 'http://[domain]/editor.php';
$dir = '/[path to file]/';
$nama = 'index.php';
// check nama, call: [$url]?nama=[file to edit]
if (isset($_GET['nama']))
{
$nama=$_GET['nama'];
}
$file = $dir.$nama;
// check if form has been submitted
if (isset($_POST['text']))
{
// save the text contents
file_put_contents($file, $_POST['text']);
// redirect to form again
header(sprintf('Location: %s', $url.'?'.'nama='.$nama));
printf('<a href="%s">Moved</a>.', htmlspecialchars($url));
exit();
}
// read the textfile
$text = file_get_contents($file);
?>
<!-- HTML form -->
<form action="" method="post">
<input name="nama" value="<?php echo $nama; ?>"/>
<textarea name="text" style="width: 100%; height:80%;"><?php echo htmlspecialchars($text) ?></textarea>
</br>
<input type="submit" />
<input type="reset" />
</form>
Sunday, August 9, 2015
PHP Online edit file
Labels:
online edit,
PHP
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment