View Single Post
Old 12-03-2007, 08:21 PM   #2 (permalink)
Wildhoney
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

I'm sure there will be a way, but I'm not so sure what that would be. Most people simply cloak the URL to the file and then use PHP to load it in using the header function. I've put you together a script that shows you how to achieve that.

Fundamentally, what it does is checks the file they're after, strips the forward slashes to prevent against relative directory trawling, checks to see it if exists, if it does then it will prompt the user to download the file.

I have even added a little mod-rewrite which allows the URL to look like so: /file/my_file.zip.

php Code:
define('FOLDER_DOWNLOAD', './downloads/');

if(isset($_GET['download']))
{
    $szFile = str_replace('/', '', urldecode($_GET['download']));

    if(file_exists(FOLDER_DOWNLOAD . $szFile))
    {
        header('Content-type: application/zip');
        header('Content-Disposition: attachment; filename="' . $szFile . '"');
        readfile(FOLDER_DOWNLOAD . $szFile);
    }
}
Attached Files
File Type: zip Download.zip (808 Bytes, 8 views)
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
The Following 2 Users Say Thank You to Wildhoney For This Useful Post:
Erutan409 (12-03-2007), Nor (12-04-2007)