Truncates an open file to the specified length in PHP
Description
The following code shows how to truncates an open file to the specified length.
Example
<?php/*w w w . j a va 2s. co m*/
//check filesize
echo filesize("test.txt");
echo "<br />";
$file = fopen("test.txt", "a+");
ftruncate($file,100);
fclose($file);
//Clear cache and check filesize again
clearstatcache();
echo filesize("test.txt");
?>
The code above generates the following result.