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("");