I used below code to force browser start download:
//send file
$fileName = basename($fullPath);
$length = filesize($fullPath);
header('Content-Type: application/octet-stream');
header("Content-Transfer-Encoding: Binary");
header('Content-length: ' . $length);
header("Content-disposition: attachment; filename=$fileName");
readfile($fullPath);
exit;
Everything's ok except total file size is not showing in browser (Firefox & Chrome). I searched the community and also test below code in htaccess with no success :
SetEnv no-gzip dont-vary
SetEnvIfNoCase Request_URI ...
My web server is Apache and PHP is in version 8.3
Is there any other option to check?
Recently I had the same problem! Suggest that add this header too rather than htaccess solution
//to show file-size in browser
header("Content-Encoding: none");