Hello.
I’ve been having problems with downloading from my site for a while. I posted to a php forum and I was told to contact my hosting service because many avenues I’ve taken should have worked.
My current download script is this:
<?php $showName = $_GET['show']; header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: public"); header("Content-Description: File Transfer"); header("Content-Type: application/octet-stream"); header("Content-Transfer-Encoding: binary"); header("Content-Length: ".filesize($showName)); header("Content-Disposition: attachment; filename=\"$showName\""); readfile($showName); ?>The download usually stops before 2 megabytes are downloaded.
The access log shows I’m getting a 500 internal error.
The error log says the file doesn’t exist, but I know that’s not true either! I say that because it does download something and the script used to work for me. I didn’t change anything. At first a few people told me they had this problem, but I could not reproduce it. Now it happens all the time and I doesn’t work for me either.
Someone suggested adding set_time_limit(0); Also tried changing Content-Type to force-download and adding clearstatcache() . None of these suggestions solved my problem.
I found this script online:
http://www.zubrag.com/scripts/download.php
It uses fopen and fread. When I use this script, I no longer see a 500 error. No error gets generated and the access log shows a 200 code, which is good.
The problem I’m having with this script is that it does download the entire file. It usually downloads at least 50% of it. Sometimes it’s well into the 90s. The mp3 will play until the file ends prematurely.
I know my problem stems from php because when I go to the podcast page, I can right-click/save the mp3s without a problem. There is also nothing wrong with the mp3s as the podcast downloads play perfectly as does the flash player that launches the files.
Is there some sort of php limitation? All the files are about 90MB since my shows are ~60 minutes.
Can anyone please help me?
Thanks!
-tony