I write a script to force download mp3 files from a site. The code is working very fine but the problem is that it can’t download large files. I tried it with a file of 9.21mb and it downloaded correctly, but whenever i try to use the code to download a file of 25mb, it simply gives me a cannot find server page or The website cannot display the page. So i now know it has problems downloading large files. Below is the code snippet that does the downloading of files.
header('Pragma: public'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Cache-Control: private',false); header('Content-type: application/force-download'); header('Content-Disposition: attachment; filename=\''.$dname.'.mp3\';' ); header('Content-Transfer-Encoding: binary'); header('Content-Length: '.filesize($secretfile)); $downloaded=readfile($secretfile);
The displayed error is: HTTP 500 Internal Server Error
thank u very much for ur time guys.
It could be memory limits, but usually PHP will output an error saying that the memory limit has been reached.
Also, before all of that you should disable output compression if it’s enabled:
Sometimes IE can screw up if output compression is enabled.