I'm having trouble creating a download script that is cross browser compatible. As it stands, it seems to work for .zip, .exe and .pdf, except the pdf doesn't work in MSIE 6+. MSIE just seems to do nothing when attempting a pdf download. My biggest problem has been Netscape spitting out a bunch of garbage code when attempting a download. Would appreciate any help. I have 2 files, the first one requests the second one. I'm not including the parse routine, trying to keep this short. Will post if you think that's the problem.
FILE 1:
#!/usr/bin/perl -wT
$| = 1;
$filename = "test.pdf";
print "Content-type: text/html\n\n";
print <<EOM;
<FORM ACTION="b2.cgi?" METHOD="POST">
<INPUT TYPE="hidden" NAME="actiontype" VALUE="dload1/i">
<input type=hidden NAME="filename" value="$filename">
<INPUT TYPE="submit" VALUE="Download">
</form>
EOM
exit;
FILE 2:
#!/usr/bin/perl -wT
$| = 1;
$filepath = "/path/httpdocs/folder/";
$filename = "test.pdf";
&read_input;
if ($data{'actiontype'} =~ /dload1/i) {
print "Content-type: application/octet-stream\n" if ($filename =~ /\.e
+xe$/);
print "Content-type: application/zip\n" if ($filename =~ /\.zip$/);
print "Content-type: application/pdf\n" if ($filename =~ /\.pdf$/);
print "Content-type: application/x-pdf\n" if ($filename =~ /\.pdf$/);
print "Content-Disposition: inline; filename=$filename\n";
print "Content-Description: File to download\n\n";
open (FILE, "$filepath$filename");
local ($/);
$file = <FILE>;
close (FILE);
print $file;
}
exit;