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;
In reply to Perl CGI download file and redirect by Yaerox
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |