So I devised a download script which handles downloads when trying to directly access PDF's in their exact location, eg:
http://www.domain.com/files/file.pdf

would now become:
http://www.domain.com/dl.php?file=file

Everything works peachy in every browser but IE, the problem with IE is that apparently it doesn't like being force-fed a download when trying to open a PDF directly off the server - instead users have to save the PDF to disk before they can view it. I have been informed that this isn't acceptable, and we need a workaround, but everything I've read on php.net as far as serving files through the header() function indicates that indeed there is no IE workaround, but I'm hoping some of the good guys here can provide something to let IE users open a PDF directly from the server without having to first download them.

Here's the code I have now with the header functions for sending the requested file to the browser:

$filetype=mime_content_type($root.$endfile);
	header('Content-type: application/force-download');
	header('Content-Disposition: attachment; filename="'.$endfile.'"');
readfile($root.$endfile);

If there's any help available, please let me know! Thanks!

    First of all, the proper MIME type to use when sending generic binary data is application/octet-stream (references RFC2045, RFC2046; the official list is maintained by the IANA).

    Second, if you want the client (i.e., the browser) to know that it is a PDF document you're sending so that it can deal with it appropriately (and not "force a download"), the MIME type you really want to use is the one that says that it is a PDF document. That's application/pdf (RFC3778).

      Originally posted by Weedpacket
      First of all, the proper MIME type to use when sending generic binary data is application/octet-stream (references RFC2045, RFC2046; the official list is maintained by the IANA).

      Second, if you want the client (i.e., the browser) to know that it is a PDF document you're sending so that it can deal with it appropriately (and not "force a download"), the MIME type you really want to use is the one that says that it is a PDF document. That's application/pdf (RFC3778).

      Well I tried not using the mime_content_type() function and just explicitly declaring both application/octet-stream and application/pdf for the Content-type, but they all produced the same error. 🙁

        Write a Reply...