CGI POST binary file upload?

Dennis Dunn ansofive at bellsouth.net
Wed Dec 6 16:39:08 CET 2000


Hi,

I've recently dealt with this exact issue.

In article <90j8j0$cmt$1 at nnrp1.deja.com>, "Bill Seitz" <fluxent at yahoo.com>
wrote:

> I tried adding msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) up at

I discovered that sys.stdout.fileno() doesn't actually return the file
descriptor like you would expect from the documentation.   However, you
can use 0 for stdin, 1 for stdout, and 2 for stderr.  (I've only actually
tested stdout, I am assuming the other two will also work.)

In my code I test for the platform and if the program is running on win32
then I set the filemode - 

if sys.platform == "win32":
	import msvcrt
	msvcrt.setmode(1), os.O_BINARY

HTH,

--dennis



More information about the Python-list mailing list