SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    I solve practical problems. bronze trophy
    Michael Morris's Avatar
    Join Date
    Jan 2008
    Location
    Knoxville TN
    Posts
    2,053
    Mentioned
    66 Post(s)
    Tagged
    0 Thread(s)

    Having trouble with a download in IE

    All other browsers working fine. Upload process works fine, even in IE.

    Relevant code.

    Code php:
    $file = $service->read((int) $_GET['id']);
    header("Content-Type: {$file['mime']}");
    header("Content-Disposition: attachment; filename=\"{$file['name']}\"");
    header("Content-length: {$file['size']}");
    ob_end_clean();
    echo $file['data'];
    exit;

    I'm guessing I'm missing a header. The $service object returns an array from the database with the original filename, mimetype, size and data. Data is stored as a BLOB in the database, other fields are text.

    Help please.

  2. #2
    SitePoint Wizard bronze trophy Immerse's Avatar
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    1,661
    Mentioned
    7 Post(s)
    Tagged
    1 Thread(s)
    What's going wrong? File not downloading? Displaying inline?

    If you look at the headers in the other browsers (using Firebug or something similar), do the three headers show up correctly?

  3. #3
    I solve practical problems. bronze trophy
    Michael Morris's Avatar
    Join Date
    Jan 2008
    Location
    Knoxville TN
    Posts
    2,053
    Mentioned
    66 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Immerse View Post
    What's going wrong? File not downloading? Displaying inline?

    If you look at the headers in the other browsers (using Firebug or something similar), do the three headers show up correctly?
    Headers show up correctly in all other browers, but IE is rejecting the file download

    "Internet Explorer cannot download mod.php from namewitheld.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."


    Yeah, not MS's most useful error message.

  4. #4
    I solve practical problems. bronze trophy
    Michael Morris's Avatar
    Join Date
    Jan 2008
    Location
    Knoxville TN
    Posts
    2,053
    Mentioned
    66 Post(s)
    Tagged
    0 Thread(s)
    Found my solution. The error stems from a bug in how IE handles HTTPS sessions (which this page is served under). The solution is to force PHP not to send a Pragma header with

    header("Pragma: ");

    More information in this blog post where I finally tracked this down at.

    Internet Explorer Can't Open Files Via HTTPS: Try Removing The Pragma Header - Mark S. Kolich

    Again, the problem is specific to HTTPS connections, which I haven't worked with on downloads before - which in turn explains why I haven't seen this before.

  5. #5
    SitePoint Wizard bronze trophy Immerse's Avatar
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    1,661
    Mentioned
    7 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by Michael Morris View Post
    "Internet Explorer cannot download mod.php from namewitheld.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."


    Yeah, not MS's most useful error message.
    Argh, that is the singularly most useless message ever.
    Once had that one because my HTML contained a self-closed div which was being updated using javascript. Yep, IE crashed because of <div/>.


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
  •