http-stream for download

Discussion in 'HTML' started by Florian Windhaus, Oct 15, 2003.

  1. Hi,

    i am creating a small server-script, which has to be able to send a file to
    the browser (file-download).

    if the browser is asking for the file, i am sending this header:
    "HTTP/1.1 200 OK
    Date: Wed, 15 Oct 2003 10:44:51 GMT
    Content-Type: application/octet-stream
    Cache-Control: max-age=0, no-cache, must-revalidate
    Expires: Wed, 15 Oct 2003 10:44:51 GMT
    pragma: no-cache
    Connection: Close
    Content-Disposition: attachment;filename=<filename>
    Content-Length: <length_of_file>"

    after this i am opening the file in binary mode and add each bit to the
    stream.

    the browser recognizes this stream as a download stream and askes me, if i
    wanna accept it. after i made my choice, i get an error message, telling me,
    that the browser is unable to open the file.

    why?
    has anyone some idea?

    th@nx Flo
    Florian Windhaus, Oct 15, 2003
    #1
    1. Advertising

  2. Florian Windhaus

    Micah Cowan Guest

    "Florian Windhaus" <> writes:

    > Hi,
    >
    > i am creating a small server-script, which has to be able to send a file to
    > the browser (file-download).
    >
    > if the browser is asking for the file, i am sending this header:
    > "HTTP/1.1 200 OK
    > Date: Wed, 15 Oct 2003 10:44:51 GMT
    > Content-Type: application/octet-stream
    > Cache-Control: max-age=0, no-cache, must-revalidate
    > Expires: Wed, 15 Oct 2003 10:44:51 GMT
    > pragma: no-cache
    > Connection: Close
    > Content-Disposition: attachment;filename=<filename>
    > Content-Length: <length_of_file>"
    >
    > after this i am opening the file in binary mode and add each bit to the
    > stream.
    >
    > the browser recognizes this stream as a download stream and askes me, if i
    > wanna accept it. after i made my choice, i get an error message, telling me,
    > that the browser is unable to open the file.
    >
    > why?
    > has anyone some idea?


    AFAICT, this seems to be a system error, rather than a server
    error. Are you sure you're saving the file to a location where
    you have appropriate permissions? Do you have disk space
    problems?

    HTH,
    Micah
    Micah Cowan, Oct 15, 2003
    #2
    1. Advertising

  3. Florian Windhaus wrote:

    > HTTP/1.1 200 OK
    > Date: Wed, 15 Oct 2003 10:44:51 GMT
    > Content-Type: application/octet-stream
    > Cache-Control: max-age=0, no-cache, must-revalidate
    > Expires: Wed, 15 Oct 2003 10:44:51 GMT
    > pragma: no-cache
    > Connection: Close
    > Content-Disposition: attachment;filename=<filename>
    > Content-Length: <length_of_file>"
    >
    > after this i am opening the file in binary mode and add each bit to the
    > stream.


    Are you leaving a blank line before sending the file? If not, do.

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me - http://www.goddamn.co.uk/tobyink/?id=132
    Toby A Inkster, Oct 15, 2003
    #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.

Share This Page