• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 494
  • Last Modified:

Masking download URL

Hello

I am adding a download section to my website, i have made an uploader and it works fine only what i need is a way for a downloader script to mask the actual URL of the file, so instead of going to /data/download.zip it will say they are downloading /index.cgi&dl=4 or something of that sort - It stops hotlinking and hides where the Downloads are, also means i can restrict how much bandwith each person uses.

Thank you
0
NapAiM
Asked:
NapAiM
  • 3
  • 2
  • 2
  • +1
1 Solution
 
ahoffmannCommented:
use your favourite programming language, open the file associated with dl=4 and return its content on stdout
What is your question now?
0
 
NapAiMAuthor Commented:
Perl with CGI
how do i post it out with STDOUT would be my new and improved question

can i make the file contencts = $var and the print $var in a form which makes the browser download it?
0
 
Perl_DiverCommented:
what scripting language are you using or thinking of using for this? perl, php, asp, other? CGI often is associated with perl but the script can be written in many different languages. You don't really need to hide the URL, you just need to download the file from a folder above the www root. Web surfers can't access folders above the www root but your scripts can.  If you don't have the abolity to store files above the www root then I suggest you change hosts.

0
Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

 
ahoffmannCommented:
# quick&dirty
use CGI;
print "Content_Type: your-type-here\n\n";
open(F,"<","dile-for-dl=4") || dir "cannot open $!";
while(<F>) { print; }
close F;
exit(0);
0
 
Perl_DiverCommented:
ahh, sorry, somehow I missed the  "Perl with CGI" in your post above.
0
 
Perl_DiverCommented:
but that's not going to force a download is it? That's going to print the file to the screen. What's the purpose of "use CGI;" in the code?
0
 
TintinCommented:
If you really want stop people downloading files without going via the appropriate frontend, make sure you put the files outside your web root where they can not be served up by the webserver in the event the person finds the download location.

Have a look at http://www.sitepoint.com/article/file-download-script-perl/2 for a download script you can base yours on.
0
 
NapAiMAuthor Commented:
Thanks Tintin

though i htaccessed off the dir with the files in it to deny all from access

i could put it in a non-accesable section but i like everything in the same area
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now