spires Posted August 17, 2006 Share Posted August 17, 2006 Hii'm trying to get a link that when clicked (not right clicked) will download a MP3 file.I think i have it working, but when the file is downloading it takes forever then crashes. Does this code look right to you.[code]$dir = '../cart/mp31/'; $file = $dir.$_REQUEST['userfile_name1'];header("Pragma: public");header("Expires: 0");header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header('Content-length: '.filesize($file));header("Content-Type: application/force-download");header( "Content-Disposition: attachment; filename=".basename($file));header( "Content-Description: File Transfer");[/code]goto:www.nickyrubin.com/membersusername = [email protected]password = p4fnhtx9thanks for anyhelp Link to comment https://forums.phpfreaks.com/topic/17872-downloading-mp3s-using-headers-is-taking-forever/ Share on other sites More sharing options...
effigy Posted August 17, 2006 Share Posted August 17, 2006 You're not sending data? Where's the [tt]@readfile($file);[/tt]? Link to comment https://forums.phpfreaks.com/topic/17872-downloading-mp3s-using-headers-is-taking-forever/#findComment-76384 Share on other sites More sharing options...
spires Posted August 17, 2006 Author Share Posted August 17, 2006 OK, that makes sence! i supose it would help.Where do i place the code. Is it at the end? Link to comment https://forums.phpfreaks.com/topic/17872-downloading-mp3s-using-headers-is-taking-forever/#findComment-76386 Share on other sites More sharing options...
akrytus Posted August 17, 2006 Share Posted August 17, 2006 Are you aware that your username and password are being sent over the url. Everyone can see them, and capture them.Try just making a link to the actual file that simple.<a href="..song.mp3">Song.mp3</a> Link to comment https://forums.phpfreaks.com/topic/17872-downloading-mp3s-using-headers-is-taking-forever/#findComment-76387 Share on other sites More sharing options...
spires Posted August 17, 2006 Author Share Posted August 17, 2006 Coool!it work wounders.thanks mate.If i link to the mp3, wount that only play the track? not download it. Link to comment https://forums.phpfreaks.com/topic/17872-downloading-mp3s-using-headers-is-taking-forever/#findComment-76388 Share on other sites More sharing options...
akrytus Posted August 17, 2006 Share Posted August 17, 2006 It shouldnt play it, that would be streaming audio or something. Never messed with that before. Should download. Link to comment https://forums.phpfreaks.com/topic/17872-downloading-mp3s-using-headers-is-taking-forever/#findComment-76393 Share on other sites More sharing options...
spires Posted August 17, 2006 Author Share Posted August 17, 2006 Just tryed it, it only plays the track. It dont download it. Link to comment https://forums.phpfreaks.com/topic/17872-downloading-mp3s-using-headers-is-taking-forever/#findComment-76394 Share on other sites More sharing options...
akrytus Posted August 17, 2006 Share Posted August 17, 2006 Huh, learned something new today! Well now I know.Also I had to login twice. Does it do that for you? Link to comment https://forums.phpfreaks.com/topic/17872-downloading-mp3s-using-headers-is-taking-forever/#findComment-76396 Share on other sites More sharing options...
spires Posted August 17, 2006 Author Share Posted August 17, 2006 Yeah, I'm not to sure why yet. I'm going try and now fix the Quantity problem, then look into that. one problem after another. Link to comment https://forums.phpfreaks.com/topic/17872-downloading-mp3s-using-headers-is-taking-forever/#findComment-76398 Share on other sites More sharing options...
ryanlwh Posted August 17, 2006 Share Posted August 17, 2006 [quote author=spires link=topic=104660.msg417596#msg417596 date=1155842498]Just tryed it, it only plays the track. It dont download it.[/quote]It downloads to the temp folder on your computer and plays it immediately with your default player. So technically you've "downloaded" it, just without the prompt. If you want to "force" download then use the php header method, and you need to print/echo the file to screen after the headers, so that user will get the data. Link to comment https://forums.phpfreaks.com/topic/17872-downloading-mp3s-using-headers-is-taking-forever/#findComment-76464 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.