[Phpwm] How to create a page on a server from a browser

Andrew Lewis andrew at monkeysailor.co.uk
Sun Apr 30 23:59:30 BST 2006


Ray Masa wrote:

> Hi all,
>
> I am developing a web based application where I can create files on 
> the server via the web browser. So that users can create and edit 
> .html files. I will have a text box on the web page which will be used 
> to name the page (e.g. about.html) and a submit button. When the 
> submit button is clicked, a page (about.html) will be created on the 
> web server (apache).
>
> Any ideas how to do that using PHP?

file access is fairly straight forward in PHP - as an example:

$outfile = "<b>Some HTML text</b>";
$fh = fopen("default.html", 'w') or die("can't create default.html file");
fwrite($fh, $outfile);
fclose($fh);

will open a file, write the contents of $outfile to the file, and then 
close the file or die with an error message if it fails. You can just 
tie this in with the submit button. There's an example of this (loading 
a config file) at www.monkeysailor.co.uk/scanui/config.php

hope this helps
spline



More information about the Phpwm mailing list