> I have a javascript to edit an html page thatI have written and have
> been searching for a way to load a file into a text box and write the
> contents to a file on the server when done in PHP. Is this possible? Any
> direction is appreciated. Thanks in advance.

<HTML><BODY><FORM METHOD=POST>
<?php
#Untested code:
    $path = "/full/path/to/file/php/can/write/to";
    if (isset($submit)){
        $file = fopen($path, 'w') or die("Unable to write to $path.  Check
permissions.");
        fwrite($file, $text, strlen($text));
        fclose($file);
    }
    $file = fopen($path, 'r') or die("Unable to read from $path.  Check
permissions.");
    $text = fread($file, filesize($path));
?>
    <TEXTAREA NAME=text COLS=60 ROWS=20><?php echo $text;?></TEXTAREA><BR>
    <INPUT TYPE=SUBMIT NAME=submit>
</FORM></BODY></HTML>

The tricky part is Security.  You really don't want a file in the middle of
your web-site that any random surfer can write to...

Using the above code as-is would be pretty foolish under virtually all web
sites.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to