Using http headers to download a file. Firefox works but IE doesn't

Discussion in 'HTML' started by igorcarajo@yahoo.com, Jul 12, 2006.

  1. Guest

    Hello,

    I am using php to send http headers back to the client to start a
    download, so that when the client requests "test.php", it gets the file
    "xyz.msi" sent back. The headers that the client receives look like
    this (I am using the same headers that osCommerce uses for downloads):

    HTTP/1.x 200 OK
    Date: Tue, 11 Jul 2006 21:31:17 GMT
    Server: Apache/2.0.50 (FreeBSD) PHP/4.3.10
    X-Powered-By: PHP/4.3.10
    Expires: Mon, 26 Nov 1962 00:00:00 GMT
    Last-Modified: Tue,11 Jul 2006 21:31:22 GMT
    Cache-Control: no-cache, must-revalidate
    Pragma: no-cache
    content-disposition: attachment; filename=xyz.msi
    Keep-Alive: timeout=15, max=100
    Connection: Keep-Alive
    Transfer-Encoding: chunked
    Content-Type: Application/octet-stream

    Well, this works fine with Firefox 1.5 and Mozilla 1.7, but Internet
    Explorer 6 fails with an error message that says "Internet Explorer
    cannot download test.php from localhost. Internet Explorer was not able
    to open this Internet site. The requested site is either unavailable or
    cannot be found. Please try again later."

    Can anyone help me figure out what the problem is? Thanks in advance.
     
    , Jul 12, 2006
    #1
    1. Advertising

  2. Guest

    Update: I eliminated the error by removing the header "cache-control",
    but now IE just displays the msi file on the screen. I think I read
    somewhere that IE doesn't pay much attention to the "content-type"
    header and instead tries to guess what type the content is. Is this
    correct? If so, how can I trick IE into not displaying it? Should I zip
    the file? Thanks.



    wrote:
    > Hello,
    >
    > I am using php to send http headers back to the client to start a
    > download, so that when the client requests "test.php", it gets the file
    > "xyz.msi" sent back. The headers that the client receives look like
    > this (I am using the same headers that osCommerce uses for downloads):
    >
    > HTTP/1.x 200 OK
    > Date: Tue, 11 Jul 2006 21:31:17 GMT
    > Server: Apache/2.0.50 (FreeBSD) PHP/4.3.10
    > X-Powered-By: PHP/4.3.10
    > Expires: Mon, 26 Nov 1962 00:00:00 GMT
    > Last-Modified: Tue,11 Jul 2006 21:31:22 GMT
    > Cache-Control: no-cache, must-revalidate
    > Pragma: no-cache
    > content-disposition: attachment; filename=xyz.msi
    > Keep-Alive: timeout=15, max=100
    > Connection: Keep-Alive
    > Transfer-Encoding: chunked
    > Content-Type: Application/octet-stream
    >
    > Well, this works fine with Firefox 1.5 and Mozilla 1.7, but Internet
    > Explorer 6 fails with an error message that says "Internet Explorer
    > cannot download test.php from localhost. Internet Explorer was not able
    > to open this Internet site. The requested site is either unavailable or
    > cannot be found. Please try again later."
    >
    > Can anyone help me figure out what the problem is? Thanks in advance.
     
    , Jul 12, 2006
    #2
    1. Advertising

  3. Rik Guest

    wrote:
    >> content-disposition: attachment; filename=xyz.msi


    I might be talking out of my ass here, bu seeing as you haven't had an
    answer yet: perhaps
    Content-disposition: attachment; filename="xyz.msi"
    ^-----------------------------------------^-------^

    Grtz,
    --
    Rik Wasmus
     
    Rik, Jul 13, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ken Cox [Microsoft MVP]

    Re: How to download file from server using http headers?

    Ken Cox [Microsoft MVP], Aug 16, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    608
    Ken Cox [Microsoft MVP]
    Aug 17, 2003
  2. mandelbort
    Replies:
    1
    Views:
    463
    S. Justin Gengo
    Aug 18, 2003
  3. Michael Foord

    HTTP Headers to make a download

    Michael Foord, Oct 12, 2004, in forum: Python
    Replies:
    2
    Views:
    344
    Michael Foord
    Oct 13, 2004
  4. Ian
    Replies:
    2
    Views:
    1,958
  5. Us
    Replies:
    14
    Views:
    999
Loading...

Share This Page