![]() |
Forced Download
1 Attachment(s)
This script will get the file name from a url, it will assume that all files to be downloaded are on the same level as the download file, e.g:
Where to place the download file: downloads/ download.php [all other files] File Linkage: If you want to link to the file, use this sort of html code: Code:
<a href="download.php?file=foo.html">Download</a>/ file-linking-to-download.html /downloads/ download.php foo.html |
Thanks a lot for being kind enough to release this script for free! It'll come in use for many people, I'm sure.
|
Thanks. Will need this in near future.
|
no probs... ;-)
|
This script is really insecure, you can just say ?file=../../../../etc/passwd or something like that, for it to be safe you need to replace this line:
PHP Code:
PHP Code:
PHP Code:
|
Quote:
|
php Code:
Result: Quote:
$file variables, because they're named the same, will have the result of the last argument set to $file. Which in my case was Test2. |
The _Download() function is declared with the first argument $f_location and the second argument $f_name (if you have read the source).
|
how can i qet this script to work?
|
What you having problems with exactly, Edwin? I'm guessing it's not a technical issue, but rather a general how to get it working?
Place your file (myFile.zip) in the downloads directory, and then link to the file like so: html4strict Code:
|
I was actually saying to myself the other day, I needed to find a script like this. Thanks a lot! I'll have to modify it a bit of course to fit my needs, but I never knew what headers to use. Thanks!
|
thanx wildhoney
|
Pleasure Edwin :-) ! Are you much of a programmer yourself? Or planning to at least get into it?
|
no im planninq to qet into it i know some php but not much.
|
It is a shame :-( Would have been nice to have seen you round here more often! Nonetheless, best of luck with the project you're using this script for. Take it easy.
|
i still dont get why you have 2 parameters in _Download, if both args take the same value (i.e. $_GET['file'] ) then whats the point, as far as i can see nothing changes the values of the parameters within the function so wouldnt this do the same:
PHP Code:
and yes sjaq is correct, you will need some form of filtering for $_GET too otherwise anything could be inputted. Other than that, good job. |
You are right, sketch. There is absolutely no need for the 2 functions because they'll go through as the same value anyway, and so if you wanted to clone the variable from within the function, you could do. And so the second argument is utterly pointless.
php Code:
|
| All times are GMT. The time now is 06:50 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0