-
Script to download a mp3
My make a webpage from my friends band and i have mp3's on there but i when ever u clik a link to them they just play from online... i would like to know how to get it to download insted of playing offline like that www.kattywhompus.cjb.net is the site so if anyone could help please let me know
-
If you have PHP capabilities with your hosting, you can use headers with the fopen feature that will force certain file types, based on what you put in your header, to download instead of just opening, thus forcing the download of an MP3 file.
Like this:
PHP Code:
header("Content-disposition: attachment; filename=$filename.mp3");
header("Content-type: application/octetstream");
header("Pragma: no-cache");
header("Expires: 0");
$client=getenv("HTTP_USER_AGENT");
$fp=fopen("$filename","r");
$str=fread($fp,filesize($filename));
echo $str;
fclose($fp);
http://www.experts-exchange.com/Web/...2.html#8621469
http://www.oxyscripts.com/manuals/ph...ion.fopen.html
http://us4.php.net/fopen