Post Reply 
looking for a PHP download script
Author Message
lembas
yuri princess

Posts: 4,365.2931
Threads: 184
Joined: 30th Apr 2008
Reputation: -2.56923
E-Pigs: 154.3525
Offline
Post: #1
looking for a PHP download script
That will give the user a file when clicked, i.e.

Code:
<a href="download.php?file=pooper.zip">DOWNLOAD</a>


I've got one of those now, and it works great,

PHP Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
 
// place this code inside a php file and call it f.e. "download.php"
$path = $_SERVER['DOCUMENT_ROOT']."/path2file/"; // change the path to fit your websites document structure
$fullPath = $path.$_GET['download_file'];
 
if ($fd = fopen ($fullPath, "r")) {
    $fsize = filesize($fullPath);
    $path_parts = pathinfo($fullPath);
    $ext = strtolower($path_parts["extension"]);
    switch ($ext) {
        case "pdf":
        header("Content-type: application/pdf"); // add here more headers for diff. extensions
        header("Content-Disposition: attachment; filename=\"".$path_parts["basename"]."\""); // use 'attachment' to force a download
        break;
        default;
        header("Content-type: application/octet-stream");
        header("Content-Disposition: filename=\"".$path_parts["basename"]."\"");
    }
    header("Content-length: $fsize");
    header("Cache-control: private"); //use this to open files directly
    while(!feof($fd)) {
        $buffer = fread($fd, 2048);
        echo $buffer;
    }
}
fclose ($fd);
exit;
// example: place this kind of link into the document where the file download is offered:
// <a href="download.php?download_file=some_file.pdf">Download here</a>


except what I really want is one that when you right click, and save as, all you get is the PHP, or somethingorother, so it basically forces users to left click on it.

Halp?

:D


I'm gay.
Spoiler for online game stuff:
[Image: 76561198003967361.png]
[Image: thelemmingbas.png]
3DS FC: 4184-1632-9353
Spoiler:
[Image: wQZsI.jpg]
Spoiler:
In the words of the wise trademark91:
windows Proud
14/12/2010 12:52 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Barcelona
Too Young To Care

Posts: 1,247.2872
Threads: 88
Joined: 10th Jul 2010
Reputation: -0.02892
E-Pigs: 60.4042
Offline
Post: #2
RE: looking for a PHP download script
id help but i don't know a spec of php :\

[Image: A73TX.png]
Quotes That Made Me Lol
Joomla12 Wrote:Who are you?
(02/08/2011 08:26 AM)eKusoshisut0 Wrote:  ┻┻ ︵ヽ(`Д´)ノ︵ ┻┻
Previous Signatures
First Signature Wrote:Rep me up or I'll GENTLY CARESS you in the booty!
Second Signature Wrote:Studies have shown that for everyone person that doesn't rep me up, an angel gets a hernea.
Third Signature Wrote:Dead Trademark91 killed me.
Fourth Signature Wrote:Windows Proud
Fifth Signature Wrote:I'm waiting for someone to chime in with an arrow. Any tamed wolves you can be traced back to my forum signature.
Sixth Signature Wrote:[Image: 7hjyW.png]
(This post was last modified: 14/12/2010 04:22 PM by ZiNgA BuRgA.)
14/12/2010 02:14 PM
Find all posts by this user Quote this message in a reply
lembas
yuri princess

Posts: 4,365.2931
Threads: 184
Joined: 30th Apr 2008
Reputation: -2.56923
E-Pigs: 154.3525
Offline
Post: #3
RE: looking for a PHP download script
lol I love useless posts!

I'm gay.
Spoiler for online game stuff:
[Image: 76561198003967361.png]
[Image: thelemmingbas.png]
3DS FC: 4184-1632-9353
Spoiler:
[Image: wQZsI.jpg]
Spoiler:
In the words of the wise trademark91:
windows Proud
14/12/2010 02:29 PM
Visit this user's website Find all posts by this user Quote this message in a reply
1-R
forced consensual sex
Team DreamArts

Posts: 5,515.3939
Threads: 396
Joined: 22nd Dec 2007
Reputation: 5.91682
E-Pigs: 115.1024
Offline
Post: #4
RE: looking for a PHP download script
(14/12/2010 02:29 PM)lembas Wrote:  lol I love useless posts!

like this? <3

[Image: OLmvS.png]
Twit | DA | G+ | Last.fm
14/12/2010 03:25 PM
Find all posts by this user Quote this message in a reply
lembas
yuri princess

Posts: 4,365.2931
Threads: 184
Joined: 30th Apr 2008
Reputation: -2.56923
E-Pigs: 154.3525
Offline
Post: #5
RE: looking for a PHP download script
Your post is far less useless. :3

I'm gay.
Spoiler for online game stuff:
[Image: 76561198003967361.png]
[Image: thelemmingbas.png]
3DS FC: 4184-1632-9353
Spoiler:
[Image: wQZsI.jpg]
Spoiler:
In the words of the wise trademark91:
windows Proud
14/12/2010 03:31 PM
Visit this user's website Find all posts by this user Quote this message in a reply
ZiNgA BuRgA
Smart Alternative

Posts: 17,023.4213
Threads: 1,174
Joined: 19th Jan 2007
Reputation: -1.71391
E-Pigs: 446.0333
Offline
Post: #6
RE: looking for a PHP download script
Right-click » Save As essentially does the same thing as left-clicking and then saving the page.

There may be some "dirty tactics" you can do but you can never guarantee that they'll work always.
14/12/2010 04:24 PM
Visit this user's website Find all posts by this user Quote this message in a reply
lembas
yuri princess

Posts: 4,365.2931
Threads: 184
Joined: 30th Apr 2008
Reputation: -2.56923
E-Pigs: 154.3525
Offline
Post: #7
RE: looking for a PHP download script
Well I don't really care  if it always works, I'd just like to thwart the average user.

Really, the only reason I'm bothering is to track downloads; to see how many people are downloading our releases, and the tracking script is an 'onclick' one.

I'm gay.
Spoiler for online game stuff:
[Image: 76561198003967361.png]
[Image: thelemmingbas.png]
3DS FC: 4184-1632-9353
Spoiler:
[Image: wQZsI.jpg]
Spoiler:
In the words of the wise trademark91:
windows Proud
(This post was last modified: 14/12/2010 04:32 PM by lembas.)
14/12/2010 04:32 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Barcelona
Too Young To Care

Posts: 1,247.2872
Threads: 88
Joined: 10th Jul 2010
Reputation: -0.02892
E-Pigs: 60.4042
Offline
Post: #8
RE: looking for a PHP download script
i had a useless post because the thread was dying >:) there is a method in my madness

[Image: A73TX.png]
Quotes That Made Me Lol
Joomla12 Wrote:Who are you?
(02/08/2011 08:26 AM)eKusoshisut0 Wrote:  ┻┻ ︵ヽ(`Д´)ノ︵ ┻┻
Previous Signatures
First Signature Wrote:Rep me up or I'll GENTLY CARESS you in the booty!
Second Signature Wrote:Studies have shown that for everyone person that doesn't rep me up, an angel gets a hernea.
Third Signature Wrote:Dead Trademark91 killed me.
Fourth Signature Wrote:Windows Proud
Fifth Signature Wrote:I'm waiting for someone to chime in with an arrow. Any tamed wolves you can be traced back to my forum signature.
Sixth Signature Wrote:[Image: 7hjyW.png]
14/12/2010 04:51 PM
Find all posts by this user Quote this message in a reply
lembas
yuri princess

Posts: 4,365.2931
Threads: 184
Joined: 30th Apr 2008
Reputation: -2.56923
E-Pigs: 154.3525
Offline
Post: #9
RE: looking for a PHP download script
The thread was dying, even though it's still the first thread on 'Latest Threads'?

I'm gay.
Spoiler for online game stuff:
[Image: 76561198003967361.png]
[Image: thelemmingbas.png]
3DS FC: 4184-1632-9353
Spoiler:
[Image: wQZsI.jpg]
Spoiler:
In the words of the wise trademark91:
windows Proud
14/12/2010 04:58 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Barcelona
Too Young To Care

Posts: 1,247.2872
Threads: 88
Joined: 10th Jul 2010
Reputation: -0.02892
E-Pigs: 60.4042
Offline
Post: #10
RE: looking for a PHP download script
yes i WAS the first to reply :)

[Image: A73TX.png]
Quotes That Made Me Lol
Joomla12 Wrote:Who are you?
(02/08/2011 08:26 AM)eKusoshisut0 Wrote:  ┻┻ ︵ヽ(`Д´)ノ︵ ┻┻
Previous Signatures
First Signature Wrote:Rep me up or I'll GENTLY CARESS you in the booty!
Second Signature Wrote:Studies have shown that for everyone person that doesn't rep me up, an angel gets a hernea.
Third Signature Wrote:Dead Trademark91 killed me.
Fourth Signature Wrote:Windows Proud
Fifth Signature Wrote:I'm waiting for someone to chime in with an arrow. Any tamed wolves you can be traced back to my forum signature.
Sixth Signature Wrote:[Image: 7hjyW.png]
14/12/2010 05:05 PM
Find all posts by this user Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread:

 Quick Theme: