Yaerox has asked for the wisdom of the Perl Monks concerning the following question:
I want to download a file and redirect to another page. Downloading the file works, but how do I get a redirect? I heared about using javascript to get this done, but I wasn't successful yet. Can you please help me out?
My basic-script without redirect (working fine):
use strict; use warnings; use CGI; my $oCGI = new CGI; my $p_filename= $oCGI->param("filename"); print "Content-Type: application/x-download\n"; print "Content-Disposition: attachment; filename=$p_filename.pdf\n\n"; unlink $p_filename;
How do I add the Javascript part? The following doesnt work:
use strict; use warnings; use CGI; my $oCGI = new CGI; my $p_filename= $oCGI->param("filename"); print "Content-Type: application/x-download\n"; print "Content-Disposition: attachment; filename=$p_filename.pdf\n\n"; print ' <html> <head> <title>Redirect</title> <script type="text/javascript"> window.onload = function(){ window.location = "my_new_url.pl?param1=123"; } </script> </head> </html>'; unlink $p_filename;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl CGI download file and redirect
by Corion (Patriarch) on Nov 17, 2014 at 14:15 UTC | |
by Yaerox (Scribe) on Nov 17, 2014 at 14:25 UTC | |
by Corion (Patriarch) on Nov 17, 2014 at 14:35 UTC | |
by Yaerox (Scribe) on Nov 17, 2014 at 14:46 UTC | |
by Corion (Patriarch) on Nov 17, 2014 at 14:50 UTC | |
|