I build the function to do this, addressing security issues by passing id variables to the force_download.php page and then that page pulls the files from the database based on the id.
The problem is that it words in every browser but Safari. In safari it will act like it is downloading and even places the file with the correct name on the desktop. But the file is 0kb and downloads in a second.
I have exhausted my search efforts and can't find a solution. I have tried different versions of my script below and none work. What am I missing for safari to be able to actually download the mp3? Any help will be appreciated.
Code: Select all
header("Pragma: public"); // required
header("Expires: 0"); // no cache
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false);
header("Content-Type: application/octet-stream;");
header("Content-Disposition: attachment; filename=\"".basename($file_name)."\";" );
header("Content-Transfer-Encoding: binary");
header("Content-Length: ". filesize($file_name)); // provide file size
set_time_limit(0);
readfile($file_name) or die("File not found."); // push it out
exit();