I have links to files (images, txts, pdfs, etc) on my server which I want to invoke the download box to appear. The options are OPEN or SAVE AS. I want all files to open in the download box whether it's an image, sound file or .zip. I searched the web and came across the stuff I'll post below. Problem is, it's in PHP. Can someone help me write this for CGI?
From the reader comments at php.net/manual http://www.php.net/manual/en/function.header.php (I'm not being a RTFM smartass, I just happened to be there very recently) simon dot lee at terago dot ca 28-May-2002 05:50 Additional notes to my workaround on Q266305: I have tested my findings with PDF, XLS, DOC and ZIP. However JPG an +d GIF didn't make IE pop up the download box. By changing content type from "octet-stream" to "force-download" (or some undefined type), it will work. Of course, we need to take care of other browsers too. Here + is the improved code, hope it helps: header("Content-type: application/force-download"); if (strstr($_SERVER["HTTP_USER_AGENT"], "MSIE")) header("Content-Disposition: filename=$myfile" . "%20"); // For IE else header("Content-Disposition: attachment; filename=$myfile"); / +/ For Other browsers Note: If you are using session together with this download, you will + need to add the following line BEFORE the code above to make IE work: session_cache_limiter("");

In reply to PHP to CGI by Anonymous Monk

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.