John Davidson

php method won't truncate text file

0 comments
Message:


I have a pre-registration data file ('tmp/data.txt') that I have to process 5 to 25 times a night at club meetings. Permissions are 644. I use an html web app to generate users' ID #'s.


sample: 10673062 12345678 etc.


After reading the file, it needs to be truncated to 0 bytes. I don't want to process the same ID #'s repeatedly.


I have tried every php trick in the book:


<script>

function remake() {

// do various js operations, then:

<?php $fh = fopen( 'tmp/data.txt', 'w' ); fclose($fh);?>
<?php file_put_contents("tmp/data.txt", "");?>
<?php $fp = fopen("tmp/data.txt", "w+"); ftruncate($fp, 0); fclose($fp);?>

// do more js stuff.

}

</script>

But the file remains intact. What do I have to do (chmod or chgrp possibly ?) to make the file accessible for truncation by php?


SOLVED: made an external php 'eraseRegs.php;' called it and it worked. Thanks!



My Answer:
The PHP method `won` does not exist in the PHP programming language. It is possible that you may be referring to a custom method or function that has been defined in a PHP script. If you provide more context or code snippets, I may be able to help you further.

Rate this post

5 of 5 based on 6088 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us