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. |