Jump to content


Photo

auto download?


  • Please log in to reply
7 replies to this topic

#1 spires

spires
  • Members
  • PipPipPip
  • Advanced Member
  • 492 posts

Posted 16 August 2006 - 07:55 PM

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
How to make over $600 a day from AdSense? Discover EXACTLY how he does it in these videos:
http://www.adsense-online.com

#2 Jocka

Jocka
  • Members
  • PipPipPip
  • Advanced Member
  • 344 posts
  • LocationDallas, Texas

Posted 16 August 2006 - 08:38 PM

you mean to keep them from seeing the link and giving it out?

#3 spires

spires
  • Members
  • PipPipPip
  • Advanced Member
  • 492 posts

Posted 16 August 2006 - 08:48 PM

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
How to make over $600 a day from AdSense? Discover EXACTLY how he does it in these videos:
http://www.adsense-online.com

#4 effigy

effigy
  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 16 August 2006 - 08:54 PM

Send them to a link that passes the mp3 over via header. For example:

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

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...
Regexp | Unicode Article | Letter Database
/\A(e)?((1)?ff(?:(?:ig)?y)?|f(?:ig)?)\z/

#5 spires

spires
  • Members
  • PipPipPip
  • Advanced Member
  • 492 posts

Posted 16 August 2006 - 09:11 PM

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.
How to make over $600 a day from AdSense? Discover EXACTLY how he does it in these videos:
http://www.adsense-online.com

#6 Jocka

Jocka
  • Members
  • PipPipPip
  • Advanced Member
  • 344 posts
  • LocationDallas, Texas

Posted 16 August 2006 - 09:14 PM

umm. try this.
http://www.phpfreaks...ic,95433.0.html

#7 effigy

effigy
  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 16 August 2006 - 09:18 PM

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.

        ### $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.
Regexp | Unicode Article | Letter Database
/\A(e)?((1)?ff(?:(?:ig)?y)?|f(?:ig)?)\z/

#8 spires

spires
  • Members
  • PipPipPip
  • Advanced Member
  • 492 posts

Posted 16 August 2006 - 09:22 PM

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
How to make over $600 a day from AdSense? Discover EXACTLY how he does it in these videos:
http://www.adsense-online.com




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users