CGI File Upload

Bill Seitz fluxent at yahoo.com
Wed Dec 6 13:23:16 EST 2000


In article <ulmttsihs.fsf at cs.uu.nl>,
  piet at cs.uu.nl wrote:
> >>>>> Bill Seitz <fluxent at yahoo.com> (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()

Yes, this turned out to be the issue. I had it set for stdout, but not
stdin.

msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY)


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list