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");
}

?>

Reply via email to