I am working with Perl and NT Server. I am trying to set up a "simple" and secure way for users to download secure zip files. I already have a javascript front end for them to log in using a preassigned u/p. After logging in it forwards them to a page listing files they are allowed to download. This page should be secure, i.e. they should only be able to get to it thru the login page. Also the files this page links to need to be secure.
I found a code snippet on this site I could use to download files, something like:
my $filepath = "<path here>";
my $filename = $ENV{'QUERY_STRING'};
my $filesize = -s "$filepath/$filename";
print "Content-disposition: attachment; filename=$filename\n";
print "Content-Length: $filesize\n";
print "Content-Type: application/octet-stream\n\n";
my $buffer;
open FILE, "$filepath/$filename" or die "Oops $!";
binmode FILE;
binmode STDOUT;
print $buffer while (read(FILE, $buffer, 4096));
close FILE;
This is the whole contents of a file I have called test.pl. I am new at this so please bear with me. I see how I can place the files to download in a non-public directory on the server, but how do I prevent a user from typing "http://website.com/cgi-bin/test.pl" right in his browser address bar? This would just download the file for them. If I change permissions on the server for my cgi-bin directory then the calling file can't access test.pl either.
Thanks - Dave
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.