Help with files
| From: | Mr. Austin | Date: | Mon, 02 Feb 2004 02:33:43 +0000 |
| Subject: | Help with files | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-176546@lists.php.net to get a copy of this message | ||
Hello all,
I am trying to open a file (successful), then rewrite over the file when it is saved via a form on a
website. I have used the following code, yet it simple rewrites from the file pointer, but does not
clear the file before writing. Thanks for any help.
<?php
$buff = fopen("sample.txt", "r+");
$text = "This is new text for yay";
if(!fwrite($buff, $text)) {
print("Unable to write to file");
} else {
print("File written successfully");
}
?>