Jump to content

Archived

This topic is now archived and is closed to further replies.

spires

Downloading mp3s using headers is taking forever?

Recommended Posts

Hi

i'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/members
username = paypal@solus-music.com
password = p4fnhtx9

thanks for anyhelp

Share this post


Link to post
Share on other sites
You're not sending data? Where's the [tt]@readfile($file);[/tt]?

Share this post


Link to post
Share on other sites
OK,

that makes sence! i supose it would help.

Where do i place the code.
Is it at the end?

Share this post


Link to post
Share on other sites
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>

Share this post


Link to post
Share on other sites
Coool!

it work wounders.
thanks mate.

If i link to the mp3, wount  that only play the track? not download it.

Share this post


Link to post
Share on other sites
It shouldnt play it, that would be streaming audio or something.  Never messed with that before.  Should download.

Share this post


Link to post
Share on other sites
Huh, learned something new today!  Well now I know.


Also I had to login twice.  Does it do that for you?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
[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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.