I am downloading large files, and have code like this:
header('Content-Type: audio/mpeg');
header('Content-Length: ' . filesize($path));
header('Content-Disposition: attachment; filename="test.mp3"');
echo file_get_contents($path);
When I click on a link to this action I have to wait a very long time (seems like browser is loading the whole file in background) before the download popup shows. Then when I click to save, it is downloaded instantly. When I comment out the line with Content-Length, the download popup shows immediately, but of course file size and percentage is not shown. Do you have any ideas?