I have a CGI that runs twice: the first time, it displays a form, then it calls itself to process the form. On the first time around, obviously I have to use content-type:text/html
But on the second time around, my visitor may have asked to download a file when he filled in the form. Now I need to change the content-type. Here is my code:
print "Content-type:application/x-download\n";
print "Content-Disposition:attachment;filename=$ID\n\n";
print @fileholder;
But it doesn't work because these print statements are interpreted to mean "print all this stuff to the screen."
How do I change the content-type in a Perl CGI?
Thanks!


Reply With Quote
Bookmarks