Here's the body of the .cgi file:
Here are the two functions in question (JavaScript):
Everything downloads fine and I get no JS errors, but the page never refreshes. What am I missing? Control is switched to the browser to download the file, but then should be switched back to the page, right?
-MT
Code:
#!/usr/bin/perl -w
use CGI qw/:standard/;
use CGI::Cookie;
use CGI::Carp qw(fatalsToBrowser);
use perlLib;
%cookies = fetch CGI::Cookie;
my $emailCookie = $cookies{'peiEmail'}->value;
my $ipCookie = $cookies{'peiIP'}->value;
my $fileName = substr $ENV{"QUERY_STRING"},32; ## not 9
my $fileLoc = '[URL unfurl="true"]http://rhlwebsvr/ftpfiles/'[/URL] . $fileName;
$fileName =~ s/\%20/ /gi unless (-e $fileLoc);
my $logFileName = $fileName;
my($localDate,$localTime) = createDateStamp();
my $timeStamp = "$localDate $localTime";
$logEntry = '<tr align=left valign=top><td><a href=mailto:' . $emailCookie . '>' . $emailCookie . '</a></td><td>' . $ipCookie . '</td><td>' . $timeStamp . '</td><td>' . $logFileName . '</td></tr>' . "\n";
open (LOG, ">>ftpLog.txt") or die "file cannot be opened.";
flock (LOG, 2);
print LOG "$logEntry";
close (LOG);
print <<"HTML code";
Content-type: text/html\n\n
<html>
<head>
<meta http-equiv="refresh" content="5; URL=http://rhlwebsvr/ftpFrame.html">
<title>File Download In Progress</title>
<link href=../ftpStyle.css rel=stylesheet type=text/css>
<script src=../jsLibFTP.js></script>
</head>
HTML code
print qq(<body onLoad="delayDownload('$fileName')">);
print <<"HTML code";
<br>
<br>
<table width=300 border=0 align=center cellpadding=0 cellspacing=0>
<tr align=center valign=top>
<td width=19 height=20><img src=../images/box_blue_corner_tl.gif width=19 height=20></td>
<td background=../images/box_blue_side_t.gif><img src=../images/box_blue_side_t.gif width=2 height=20></td>
<td width=19 height=20><img src=../images/box_blue_corner_tr.gif width=19 height=20></td>
</tr>
<tr align=center valign=top>
<td background=../images/box_blue_side_l.gif><img src=../images/box_blue_side_l.gif width=19 height=2></td>
<td bgcolor=#6699CC>
<h5>Your file is currently downloading...</h5>
<img src=../images/progressBar.gif width=225 height=14>
<br>
<br>
If your file does not download,<br>
HTML code
print "please click <a href=" . $fileLoc . ">HERE</a>"; # $fileLoc will be supplied by the form.
print <<"HTML code";
<br>
<br>
</td>
<td background=../images/box_blue_side_r.gif><img src=../images/box_blue_side_r.gif width=19 height=2></td>
</tr>
<tr align=center valign=top>
<td width=19 height=20><img src=../images/box_blue_corner_bl.gif width=19 height=20></td>
<td background=../images/box_blue_side_b.gif><img src=../images/box_blue_side_b.gif width=2 height=20></td>
<td width=19 height=20><img src=../images/box_blue_corner_br.gif width=19 height=20></td>
</tr>
</table>
<br>
<div align=center><strong>Version 2.0</strong></div>
<br>
<br>
</body>
</html>
HTML code
Here are the two functions in question (JavaScript):
Code:
function delayDownload(fileName) {
fullURL = "[URL unfurl="true"]http://rhlwebsvr/ftpfiles/"[/URL] + fileName;
window.setTimeout("processDownload(fullURL)", 2000);
}
function processDownload(fullURL) {
window.location.href = fullURL;
}
Everything downloads fine and I get no JS errors, but the page never refreshes. What am I missing? Control is switched to the browser to download the file, but then should be switched back to the page, right?
-MT