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;

In reply to download hidden files by hopalong

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.