I'm trying to log downloads of certain files, so I ran to the type of
http://somewhere.com/fetch.pl?id=Application1, this is how I thought of it :
I will get the id, search if I actually have it, if I do, read the file, and spit the contents to the browser
I then wanted to restrict downloads through this script, so that people cannot know the real location of the file and download it directly. so what I need is: have a file called foo_application1_bar.zip (or other) and then when I spit the contents to the browser I want to specify the filename to save with ex: Application1.zip
I wrote a little script to test with :
#!/usr/bin/perl -w
open (ZIP, "test.zip");
binmode(ZIP);
@all = <ZIP>;
close(ZIP);
print "Content-type: application/zip\n\n";
foreach (@all) {
print;
}
this ran, I have a "save file to disk" message with the default filename fetch.pl and having the .pl extension associated with a prog on my pc, I couldn't change the extension. but when I renamed the file to fetch.zip it opened and was the file requested.
How can I specify the filename to save? I think it's a header but I can't find it.
Note:
I know that the script is badly programmed and I should die on open failure and stuff, but as I said I was only testing.
Chady |
http://chady.net/
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.