http-stream for download

F

Florian Windhaus

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
 
M

Micah Cowan

Florian Windhaus said:
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
 
T

Toby A Inkster

Florian said:
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top