Am using the code below to download a file. it uses flush() and ob_flush() functions. I read brenns10 comment's at this link
It says that use of flush() and ob_flush() will cause the data to go in memory until it's displayed and as such that its not good for server with limited resources. Am on a shared server.
Please I need an explanation on this. should I flush() and ob_flush() as its in the code below or should I remove it. Thanks
$download_file = '10gb_file.zip';
$chunk = 1024; // 1024 kb/s
if (file_exists($download_file) && is_file($download_file)) {
header('Cache-control: private');
header('Content-Type: application/octet-stream');
header('Content-Length: ' . filesize($download_file));
header('Content-Disposition: filename=' . $download_file);
$file = fopen($download_file, 'r');
while(!feof($file)) {
print fread($file, round($chunk * 1024));
ob_flush();
flush();
}
fclose($file);
}