I referred to these questions and implemented their answers but none of them is working for me.
download mp3 instead of playing in browser by default?
content type for mp3 download response
download mp3 from web url with android failed
Basically when the user clicks a download link on the website, we want the user to be prompted to download the audio file.
Code :
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: $mtype");
header("Content-Disposition: attachment; filename=".$file_name);
readfile($fname);
header("Content-Transfer-Encoding: binary");
header("Content-Length: " . $fsize);
Here, $mtype
is "audio/mpeg"
Success :
- It's working fine on all desktop browsers.
- I tried with a BlackBerry, and I got the downloaded file.
Failure :
- when i do same with android browsers, I did't get the downloaded file.
- file name also missing, comes with
<untitled>
and shows the status"download unsuccessful"
.
Thank you if you have any idea why this code doesn't work on an Android phone.