in reply to Perl CGI : Output to HTML and download a file
You cannot do download and display in the same request.
I suggest that you add a CGI parameter, type and use it as follows:
my $type= $q->param('type'); $type ||= 'display'; if( 'display' eq $type ) { # output Content-Type: text/html # Output HTML page } elsif( 'download' eq $type ) { # output Content-Type: application/x-download # Output file } else { # Should never get here unless somebody has misconfigured the scri +pt or is playing around with the parameters # output Content-Type: text/html # Output HTML page };
If you want to do "both", display and download, you need to first display the HTML page and then redirect to the download link.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perl CGI : Output to HTML and download a file
by Pav (Initiate) on Aug 12, 2014 at 11:54 UTC | |
by Corion (Patriarch) on Aug 12, 2014 at 12:04 UTC |