in reply to Re^4: Perl CGI download file and redirect
in thread Perl CGI download file and redirect

That's just not possible.

After sending a HTTP response that gets saved to a file, you cannot send any more data.

  • Comment on Re^5: Perl CGI download file and redirect

Replies are listed 'Best First'.
Re^6: Perl CGI download file and redirect
by Yaerox (Scribe) on Nov 17, 2014 at 14:58 UTC
    That's exactly what I don't understand. What make the difference, that my way won't work compared to what you said "reverse the steps you're doing"?

    I got 4 scripts. Script 1 showing a form. If sending the form, script 2 is working with the data printing meta-redirect tag to script 3. Why I can't say download and redirect to script 4?

    If I would leave script 3 and call script 4 with one parameter more, nothing will be shown, because I had to use the content-type in script 4 which won't show my html. - Expected it would show something, would I be able to click links in this case?


    Edit: What about using javascript opening a new tab calling my download script there. Should be possible?

      A file download is not interpreted as HTML.

      You can only output one set of headers. If you output the headers for the download first, you will never be able to send the user to another page to send more data to the user.

      I suggest you learn HTTP and how the different content types and headers work.

        Firstly thank you very much Sir!

        The day I got this problem, I was pretty whacked. I know HTTP and this in mind I was even more wondering why I didn't understood it the day. Anyway, today, mind is free and I'll do this using Javascript popup and timer.

        Thanks for your help. Have a nice day.