Optimizing memory usage and changing file contents with PHP
- by errata
In a function like this
function download($file_source, $file_target) {
$rh = fopen($file_source, 'rb');
$wh = fopen($file_target, 'wb');
if (!$rh || !$wh) {
return false;
}
while (!feof($rh)) {
if (fwrite($wh, fread($rh, 1024)) === FALSE) {
return false;
}
}
fclose($rh);
fclose($wh);
return true;
}
what is the best way to rewrite last few bytes of a file with my custom string?
Thanks!