CGI File Upload

piet at piet at
Wed Dec 6 09:59:43 EST 2000

>>>>> Bill Seitz <fluxent at> (BS) writes:

BS> Hmm, this works for me with text data (though the file length is
BS> slightly different: maybe line-end changes from Win to *nix?). With
BS> binary it's totally off. Uploading a JPEG I consistently only get 109
BS> bytes written to the file system. With GIFs I consistently get ~500
BS> bytes (but not always exactly the same number). With an MsWord file I
BS> get a bigger file written, but still not the whole thing (60kb out of
BS> 75kb).

BS> What do I do next?

Is your server on Windows? Then it probably is a matter of the standard
input being in text mode rather than binary mode.
So you have to set it to binary mode before anything is read from it.

See msvcrt.setmode()
Piet van Oostrum <piet at>
Private email: P.van.Oostrum at

More information about the Python-list mailing list