Jump to content

Archived

This topic is now archived and is closed to further replies.

sesstreets

Bit confused, how should I update a file?

Recommended Posts

Im trying to write a script that will:

1. Open a file and display the files content into an editable box.
2. On the press of a submit button, it will update the file.

How do I do this? Ive tried fopen and get_file_contents but neither really works

Share this post


Link to post
Share on other sites
<?php
$file = 'my/path/file';

  if(isset($_POST['submit'])
 {
  $filestring = $_POST['filestring'];
 file_put_contents($file, $filestring);
 }

$filestring = file_get_contents($file);
?>
<form action="" method="post">
<textarea name="filestring">echo $filestring</textarea>
<input type="submit" name="submit" value="Submit">

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.