AFAIAA your requirement cannot be satisfied without resorting to something like AJAX. A single CGI script can either display a page or return content as a download but not both. This is because the content type is specified by the Content-Type header and this can only be given once per request. In your code above you give this twice (see the two calls of the header() method) and so the second one has little effect which is why your file contents appear in the web page.
Either resort to AJAX or consider a different way of delivering the content to the user.
In reply to Re: CGI - Creating Multipart Form with a File Download
by hippo
in thread CGI - Creating Multipart Form with a File Download
by stefl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |