force download sound file
Posted: Sun May 18, 2008 3:03 am
hi, i need to be able to let the user download a sound file instead of having it stream in the browser. after snooping around a few forums i found the best way would be to set content-disposition headers...
so i wrote this little page:
problem is, it only downloads 2-300kb and then just stops. also the download dialog (ie and firefox) doesn't get the filesize... what am i doing wrong? is it because the server is timing out?
so i wrote this little page:
Code: Select all
<?php
extract($_GET);
$fullpath="http://.../uploads/$filename.$format";
header("Content-disposition: attachment; filename=$filename.$format");
header("Content-type: audio/$format");
header("Content-Length: " . filesize($fullpath));
readfile($fullpath);
?>