FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Privitize Your Downloads.





moejoe
I need to privatise my download links, so know-one really knows the true DIR of the download.

I've found this script, although it only downloads my download.php [The actual script, and not the .zip file i wanted to download]! Why!?



Code:

// download.php Script

$fileLocation = '/home/domains/your.domain/public_html/download/';
$file = 'filename.zip';

header("Cache-control: private");
header('Content-Description: File Transfer');
header('Content-Type: application/force-download');
header('Content-Length: ' . filesize('$fileLocation' . $file));
header('Content-Disposition: attachment; filename=' . $file);


So what am i doing wrong?
n0obie4life
Code:
$fileLocation = '/home/domains/your.domain/public_html/download/';
$file = 'filename.zip';


$fileLocation is relative to the root path of your download.php file.
roee
check for this:
1. location is okay
2. file has 777 chmod
simplyw00x
Code:
header('Content-Disposition: attachment; filename=' . $file);

The filename needs to be an absolute path of some kind, or maybe relative to download.php.
moejoe
No Luck...
Sad

I've tried what you have said but it just downloads the download.php and not the file...

Below is my sites download script:

Code:

//The $file Var comes from MySQL which is code above this one

$fileLocation = '/home/moejoe/domains/unlockit.frih.net/public_html/mobilefun/videos/download';

header("Cache-control: private");
header('Content-Description: File Transfer');
header('Content-Type: application/force-download');//What about if i wanted to download lets say a Video Do i change the Type?
header('Content-Length: ' . filesize('$fileLocation' . $file));
header('Content-Disposition: attachment; filename=' . $file);


Thanks Guys,
moejoe
Well that was a stupid Mistake.


Quote:
Code:
//The $file Var comes from MySQL which is code above this one

$fileLocation = '/home/moejoe/domains/unlockit.frih.net/public_html/mobilefun/videos/download/'; /*STUPID MISTAKE! MAKE SURE YOU PUT THE '/' */ 

header("Cache-control: private");
header('Content-Description: File Transfer');
header('Content-Type: application/force-download');//What about if i wanted to download lets say a Video Do i change the Type?
header('Content-Length: ' . filesize('$fileLocation' . $file));
header('Content-Disposition: attachment; filename=' . $file);


This is not the final Script..
Oh No, The Tutorial that i downloaded need more then just half the script So here it is:

This is the FULL fininshed file WITH Speed Limiting:

Code:
<?php

$fileName = 'myFiles.zip';
$fileLocation = '/home/domain.com/httpdocs/hiddenDownloads/';

/* In kB/s */
$speed = 10;

header("Cache-control: private");
header('Content-Description: File Transfer');
header('Content-Type: application/force-download');
header('Content-Length: ' . filesize($fileLocation . $fileName));
header('Content-Disposition: attachment; filename=' . $fileName);

if (!$file = fopen($fileLocation . $fileName, 'r')) {
    exit;
}

while (!feof($file)) {
    echo fread($file, $speed * 1024 * 8);
    flush();
    sleep(1);
}

@fclose($file);
?>


Thanks To
PHPNERDS.COM

Thanks for all your help!
Related topics
Freeware downloads
Unlimited Downloads - Templates, Scripts, eBooks
Opera Reaches One Million Downloads in Two Days
skyy.0nyx.com | Dashboard | Quartz | Downloads
5000 FREE SOFTWARE downloads for Windows XP from microsoft
Can we add downloads to our site???
Downloads
Downloads
Get 12 free itunes song downloads [UK only]
Downloads manager script
[man]cambiar el orden de los Downloads?, la respuesta aqui
Java Downloads
Protect Downloads??
FREE unlimited uploads and downloads file hosting
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.