Creating files with php is very simple. So.. let's start.
Code:
<?php
// This function shows your form
function form(){
echo "<form action='?act=create' method='post'>"
."Filename: <input type='text' name='filename' size='30'><br>"
."<textarea cols='50' rows='10' name='content'></textarea><br>"
."<input type='submit' value='Create'>"
."</form>";
}
// This function will create your file
function create(){
// Gather info into variables from our form
$filename = $_REQUEST['filename'];
$content = $_REQUEST['content'];
// Now let's create our file
$open = fopen($filename, "a"); // Now this file is ready for overwriting
fwrite($open, $content); // This will write your text what was in textarea into your file
fclose($open); // Closes your file
echo "File is created <a href='$filename'>Preview</a>";
}
switch($act){
default;
form();
break;
case "create";
create();
break;
}
?>
I hope it helped..
Regards Jaan
Bookmarks
Algorithms and Data Structures
Java tutorials
Algorithms Forum