SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Sep 2005
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    IE 6 and 7 won't download dynamic pdf file

    I have a slew of pdfs that are stored in mysql as blobs (lets not talk about it, I'm still happy with this decision and it was made for good reasons). The table for these pdfs includes the pdf itself and a preview png also as a blob. When I need to retrieve the pdf I display the preview and link to the pdf like this:
    Code:
    <a href='file.php?name=$name&type=pdf&file=$id' title='$name'><img src='file.php?name=$name&type=preview&file=$id /></a>
    What this does is grab the preview image and make it a link to the PDF.

    file.php serves up the request for the PDF like this
    Code:
    $query = "SELECT `File` FROM pdf WHERE `ID`={$fileid}";
    $blob = $result['File'];
    header("Content-type: application/pdf");
    header('Content-Length: '. strlen($blob));
    header('Content-Disposition: attachment; filename="file.pdf"');
    print $blob;
    exit();
    This all works great in Firefox, Safari, and Opera but fails miserably in IE. With IE the preview displays just fine however clicking on the link gives a popup error message "Internet explorer cannot download file.php from site.com. Internet explorer was not able to open this Internet Site. The requested site is either unavailable or cannot be found. Please try again later."
    This error has been verified on 3 systems running either IE6 or IE7 with windows XP. The only solutions I have been able to find online seem to be user-centric and involve viruses and other assorted IE problems, or reference old MS instructions from 5.5. Does anyone have any idea what is going on here, and why it is only affecting IE?

  2. #2
    SitePoint Member
    Join Date
    Sep 2005
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have discovered two solutions. The problem seems to be the IE refuses to cache files over ssl because of a bug in the way it handles http 1.1 headers. This is extenuated by php sending a no-cache header by default when using session_start(). There are two answers:
    1) put session_cache_limiter('public'); in front of session_start()
    2) send header("Pragma: public")

    I have no idea what the advantages of either of these methods is. I do know that the Pragma header is an instruction to proxy servers, so I'm unclear why that works.

    Any thoughts? Does either of these methods compromise either ssl or session security?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •