CGI File Upload

Fredrik Lundh fredrik at effbot.org
Wed Dec 6 15:55:49 EST 2000


Bill Seitz wrote:
> 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)

an easier (and more portable) solution is to do what the
FAQ says, and run Python with the -u option:

    http://www.python.org/doc/FAQ.html#7.12

    "7.12. cgi.py (or other CGI programming) doesn't
    work sometimes on NT or win95!"

    Be sure you have the latest python.exe, that you are using
    python.exe rather than a GUI version of python and that you
    have configured the server to execute

         "...\python.exe -u ..."

    for the cgi execution. The -u (unbuffered) option on NT
    and win95 prevents the interpreter from altering newlines
    in the standard input and output. Without it post/multipart
    requests will seem to have the wrong length and binary
    (eg, GIF) responses may get garbled (resulting in, eg,
    a "broken image").

</F>







More information about the Python-list mailing list