Jump to content

auto download?


spires

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.