https office file download with IE

Discussion in 'PHP' started by neplasco, Jun 10, 2009.

  1. #1
    :confused: (just to reassume my situation)

    Hello to all,

    I'm italian and my english is quite poor, so excuse for my english...

    I had configured Apache with SSL to implement an https server.
    Naturally I use Apache(SSL)+PHP+MySQL.
    It seems to work properly... until you don't use MS Internet Explorer!!!
    When you try to dowload an office document, like explained in the MS site, IE signals an error

    http://support.microsoft.com/kb/316431/en

    MS suggests to eliminate the no-cache directive but I can't make it to work...

    someone can suggest anything to me (different by "don't use IE!") ?

    thanks
     
    neplasco, Jun 10, 2009 IP
  2. stOK

    stOK Active Member

    Messages:
    114
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #2
    This is IE issue.
    If you are trying open the document directly you can instead try download it and store localy first and then open in within application from local storage.
    If you have control over your apache/PHP you have to eliminate
    cache-control: no-cache header in responses.
    Using PHP it can be acheived
    <?php
    header('Cache-control:');
    header('pragma:');
    ?>
    Not tested though.
     
    stOK, Jun 10, 2009 IP
  3. neplasco

    neplasco Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thank for the answer but I can't make it to work!

    The original code is:

    <?php
    header("Content-Type: application/vnd.ms-word");
    header("Expires: 0");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("content-disposition: attachment;filename=Document.doc");
    ... code that produce html page ...
    ?>

    I have updated as following:

    <?php
    header('Cache-control:');
    header('pragma:');

    header("Content-Type: application/vnd.ms-word");
    //header("Expires: 0");
    //header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("content-disposition: attachment;filename=Document.doc");
    ... code that produce html page ...
    ?>


    just another information: the file that I produce is an html page but defining it as a doc file MS Word is able to open it directly (with no manual activity by the user).
    I don't think that this could produce the error, I explained just for completeness.

    bye
     
    neplasco, Jun 10, 2009 IP