PDA

View Full Version : Clearing File Content


Troy297
12-09-2006, 09:48 PM
Hi Again...

How might I clear a files content on my webserver from a page on my site? It would be best if activated by a link but anything will do!

I would use the file() but I have no-idea where to start....

Thanks!

Tyree
12-10-2006, 03:30 AM
Something like this could work. I've only dealt with files a handful of times though.


$file= fopen("<file_path>", "w");
fwrite($file, '');
fclose($file);


That should just clear the contents of the file but leave the file itself.

mjones74
12-11-2006, 07:05 AM
Hmm, what happens when ten people are using that file, and one of those ten threads deletes it? Just curious.

Troy297
12-11-2006, 09:37 PM
Well.... it isn't designed for use in a thread-like system. I just want to be able to clear a user log file.

I used two seperate files to store and view the logs so I just need to be able to clear the file where the logs are stored from the file where they are viewed!

Tyree
12-11-2006, 09:59 PM
Will my suggestion not work?