Mr. Austin wrote:

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

?>


Use the manual, Luke.


http://us4.php.net/manual/en/function.fopen.php

The word you're looking for here is 'truncate'.

--
By-Tor.com
It's all about the Rush
http://www.by-tor.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to