I have a filelist.txt file and I created a file called clear.php to clear the content of filelist.
I put a button in index.html to call clear.php to clear the file.
Can anyone help me out regarding what PHP code I should write in clear.php?
How to code a button to call clear.php and then return back to index.html showing the result that it has been cleared?
To add button you may use either jQuery libraries or simple Javascript script as shown below:
HTML link or button:
Javascript:
Use PHP to clear a file content. For instance you can use the fseek($fp, 0); or ftruncate ( resource $file , int $size ) as below:
Redirect PHP - you can use header ( string $string [, bool $replace = true [, int $http_response_code ]] )
I hope it's help.