Register Advertise with usHelp Desk Today's Posts Search

Closed Thread
Thread Tools Search this Thread
Unread 11th Apr 2013, 10:05 AM   #1
The Cave Man
War Room Member
 
JagSEO's Avatar
 
Join Date: 2010
Posts: 334
Thanks: 59
Thanked 96 Times in 79 Posts
Default
[Help] Random File Download Script
Share on: 
fb share twitter share gplus share more share

Hi Guys I want to know if there is someone here knows a script on downloading random files.

Example I have a download link and I have different files link like file1 link, file2 link, file3 link etc.

if someone click the download link the script will automatically randomly pick a file on different files link and will automatically download.
JagSEO is offline  
Unread 11th Apr 2013, 10:22 AM   #2
Advanced Warrior
War Room Member
 
Brandon Tanner's Avatar
 
Join Date: 2006
Location: USA
Posts: 1,907
Thanks: 236
Thanked 1,377 Times in 676 Posts
Default
Re: [Help] Random File Download Script
Share on: 
fb share twitter share gplus share more share

Easy. Assuming you have 4 files, named file1.zip, file2.zip, file3.zip, file4.zip, and those files are in the same directory as your webpage...

<a href="<?php echo 'file' . rand(1,4) . '.zip'; ?>">Click here to download</a>

Just change the '4' to the number of files you have, and be sure to give that page a PHP extension.


Brandon Tanner is offline  
Unread 11th Apr 2013, 10:41 AM   #3
The Cave Man
War Room Member
 
JagSEO's Avatar
 
Join Date: 2010
Posts: 334
Thanks: 59
Thanked 96 Times in 79 Posts
Default
Re: [Help] Random File Download Script
Share on: 
fb share twitter share gplus share more share

Thanks Brandon, how about if the files are hosted in file hosting website and all I have is the links of the files. How can I do that?

Example someone pay me in my paypal account and after paying they will receive a random downloaded file. The files are hosting in a file hosting website so how can I do the script?

Hooked To Success -Personal development For People Who Wants Success.
JagSEO is offline  
Unread 11th Apr 2013, 11:08 AM   #4
Advanced Warrior
War Room Member
 
Brandon Tanner's Avatar
 
Join Date: 2006
Location: USA
Posts: 1,907
Thanks: 236
Thanked 1,377 Times in 676 Posts
Default
Re: [Help] Random File Download Script
Share on: 
fb share twitter share gplus share more share

If the URL's of the files on the file hosting site don't have a consistent naming pattern (most likely the case), then you would have to use conditional statements, like...

<?php

$random = rand(1, 3);


if ($random == "1")
{ $link = "http://www.FileHostingWebsite.com/file1.html"; }
elseif ($random == "2")

{ $link = "http://www.FileHostingWebsite.com/file2.html"; }
elseif ($random == "3")

{ $link = "http://www.FileHostingWebsite.com/file3.html"; }

?>

^ You can probably figure out which parts of the code you have to change, but if not, just let me know. Put all of that code at the very top of the page, above all other HTML code. Then use the following code wherever you want the link to appear....

<a href="<?php echo $link; ?>">Click here to download</a>


Brandon Tanner is offline  
Unread 11th Apr 2013, 11:16 AM   #5
The Cave Man
War Room Member
 
JagSEO's Avatar
 
Join Date: 2010
Posts: 334
Thanks: 59
Thanked 96 Times in 79 Posts
Default
Re: [Help] Random File Download Script
Share on: 
fb share twitter share gplus share more share

OK Thanks I will try it out.

Hooked To Success -Personal development For People Who Wants Success.
JagSEO is offline  
Closed Thread


Bookmarks

Tags
download, file, random, script


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 02:46 PM.