I have a CGI, which optionally gives the output as a gzipped stream, rather than as text or html. I do that with the following:
use Compress::Zlib;
if($out eq 'gz'){
binmode STDOUT;
print("Content-type: application/x-gzip\n\n");
my $gz = gzopen(\*STDOUT, "wb")
or die "Cannot open stdout: $gzerrno\n" ;
foreach my $line (@lines){
$gz->gzwrite($line)
or die "error writing: $gzerrno\n" ;
}
$gz->gzclose;
}
This is working fine, but I'd like to alter the name of the output. Right now the output is saved as "name_of_CGI_script.gz" (only tested with Safari so far, other browsers/OS may behave differently.). How can I change to a default file name related to other options the user has selected? Also, how could I make that be a suggested file name, which causes a local "Save As..." dialog to appear (again, I realize there might not be a 100% universal answer for all Browser/OS combos.)
-albert
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.