genu Posted November 5, 2008 Share Posted November 5, 2008 Hi, i've been working on a function to fetch and "mp3" from a server, and display the "Download" dialog in order to download it. it looks like this: header("HTTP/1.1 200 OK"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Expires: 0"); header("Content-Length: ".$filesize); header("Content-Type: application/force-download"); header("Content-Disposition: attachment; filename=".$filename); header("Content-Transfer-Encoding: binary"); Basically, I'm trying to avoid the mp3 to open with the default player. That function works that it opens the download dialog. The problem is that the file is 0bytes after download. Am I missing something? Link to comment https://forums.phpfreaks.com/topic/131522-solved-header-function-doesnt-work/ Share on other sites More sharing options...
flyhoney Posted November 5, 2008 Share Posted November 5, 2008 I think you have to actually output the file, right? You need to add something like this at the end of that script: readfile($filename); Link to comment https://forums.phpfreaks.com/topic/131522-solved-header-function-doesnt-work/#findComment-683049 Share on other sites More sharing options...
rhodesa Posted November 5, 2008 Share Posted November 5, 2008 yeah...is there more to script? Link to comment https://forums.phpfreaks.com/topic/131522-solved-header-function-doesnt-work/#findComment-683071 Share on other sites More sharing options...
genu Posted November 5, 2008 Author Share Posted November 5, 2008 After I posted this, I continue to serach google and PHP.net, and After I added readfile($filename); it seems to have worked. I appreciate the replies...thank you Link to comment https://forums.phpfreaks.com/topic/131522-solved-header-function-doesnt-work/#findComment-683080 Share on other sites More sharing options...
genu Posted November 5, 2008 Author Share Posted November 5, 2008 Hey, now that I got this function to work. Is it possible to get the same effect from another function that has allow_url_fopen dissabled on the server? Link to comment https://forums.phpfreaks.com/topic/131522-solved-header-function-doesnt-work/#findComment-683134 Share on other sites More sharing options...
rhodesa Posted November 5, 2008 Share Posted November 5, 2008 you can use cURL, but that is kind of silly, since it would download the remote file to your server, then send it to the user... Link to comment https://forums.phpfreaks.com/topic/131522-solved-header-function-doesnt-work/#findComment-683141 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.