Jump to content

Archived

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

spires

auto download?

Recommended Posts

Hi,

Does any one know if you can download a mp3 when a page opens? (onLoad etc)

I'm am creating a shopping cart that sells MP3s, if i use RIGHT CLICK and SAVE TO DESKTOP,
the customer can download as many as they want.

Does any one know of a way around this. some kind of function that can read the RIGHT CLICK perhaps?

Thanks for your help

Share this post


Link to post
Share on other sites
you mean to keep them from seeing the link and giving it out?

Share this post


Link to post
Share on other sites
No,

the page itself uses session and a login system, so they cant give the link out.

I'm trying to find a way where they cant keep right clicking the track, and downloading as many as they want.

I need to find a way where if you click the link it will automaticaly download  to their desktop OR
link to a page that has some kind of - onLoad download track to deasktop function.

There must be some way of limiting them to only one download?

Is there any way of controlling the right click function through php?

thanks for any help :D
Jeff

Share this post


Link to post
Share on other sites
Send them to a link that passes the mp3 over via header. For example:

[code]<a href="get_mp3.php?mp3=band-song.mp3">Download</a>[/code]

In get_mp3.php, check their information against the database to see if they've already downloaded the file. If not, update the information and use header commands to send the mp3. I'm not sure how to verify that the download was successful though...

Share this post


Link to post
Share on other sites
Thanks.

I have had it before where i send them to another page, but i still have the same problem of getting the mp3 to download automatically. they still have to right click a link to download the file.

As far as i can tell, there is no way of downloading without right clicking and saving to desktop.
if you just click, it only plays the track. Doesn't download it.

any more suggestions please.

Share this post


Link to post
Share on other sites
umm. try this.
http://www.phpfreaks.com/forums/index.php/topic,95433.0.html

Share this post


Link to post
Share on other sites
Left clicking a link can start a download. Here's an example from an old piece of code; I would do some research to make sure this is still the preferred approach.

[code]
        ### $mp3 is the full path to the mp3.
$file_size = filesize($mp3);
$fp = fopen($mp3, 'r');
$buffer = fread($fp, $file_size);
header("Content-type: application/x-octet-stream"); ### You should be able to use the mp3 type here.
header("Content-disposition: attachment;filename=".basename($mp3));
header("Content-length: $file_size");
echo $buffer;
[/code]

[b]Update:[/b] Try the link Jocka provided.

Share this post


Link to post
Share on other sites
Thanks guys

I will try all of those out. At least i know i can actually be done now.

And i now see what you mean effigy, by using headers.

Cheers

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.