studiati questo 
richiamalo passandogli come paramtro il nomefile (es.: texteditor.php?filename=aaa.txt)
Codice PHP:
<?php
$msg="";
if(isset($_POST['filename']) && isset($_POST['invia'])){
file_put_contents($_POST['filename'],$_POST['content']);
$msg="file {$_POST['filename']} salvato!!";
$_GET['filename']=$_POST['filename'];
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs" lang="cs">
<head>
<meta name="generator" content="PSPad editor, [url]www.pspad.com[/url]" />
<meta http-equiv="content-type" content="text/html; charset=iso-8859-2" />
<title>Editor</title>
</head>
<body>
<?php
if(isset($_GET['filename'])){
$filename=$_GET['filename'];
$content=file_get_contents($filename);
?>
<div align="center"><?php echo $msg ?></div>
<form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>">
<textarea name="content" style="width: 100%; height: 300px;"><?php echo $content ?></textarea>
<p align="center">
<input type="submit" name="invia" value="salva" />
<input type="button" name="invia" value="annulla" onCLick="history.back()" />
</p>
<input type="hidden" name="filename" value="<?php echo $filename ?>" />
</form>
<?php
}
?>
</body>
</html>