Posted 16 August 2006 - 07:55 PM
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
Posted 16 August 2006 - 08:38 PM
Posted 16 August 2006 - 08:48 PM
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
Posted 16 August 2006 - 08:54 PM
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...
Posted 16 August 2006 - 09:11 PM
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.
Posted 16 August 2006 - 09:18 PM
### $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;
Update: Try the link Jocka provided.
Posted 16 August 2006 - 09:22 PM
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.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users