I have following problem:
I'm using module cgi.py for file upload from html form. Configuration
is WinNT 4.0 SP3, IIS 3, ActivePython Build 210.
Scripts:
upload.py:
---------
print "Content type: text/html"
print
print "<title>File upload - form</title>"
print "<html><body><p>"
print """
<html>
<body>
<form enctype="multipart/form-data" method="POST" action="uploader.py">
Insert file name:
<input type="file" size="40" name="UploadedFile">
<input type="submit" name="Submit" value="OK">
</form>
</body>
</html>
"""
uploader.py:
-----------
import cgi
import msvcrt
msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY)
print "Content type: text/html"
print
print "<title>File upload - work</title>"
print "<html><body><p>"
form = cgi.FieldStorage()
print "done!!"
print "</p></body></html>"
Problem is: Script uploader.py never prints "done!!!". It seems
cgi.FieldStorage() is waiting for something.
When I try to do some work by hand:
uploader_a.py:
-------------
import sys
import os
msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY)
print "Content type: text/html"
print
print "<title>File upload - work</title>"
print "<html><body><p>"
length = int(os.environ["CONTENT_LENGTH"])
content = ""
while 1:
line = sys.stdin.readline() # without length !!
content += line
if not line:
break
print "done!!"
print "</body></html>"
symptoms are same.
My conclusion is, that I have to read _only_ number of bytes corresponding to
CONTENT_LENGTH but cgi.py does not it.
I'm welcome any advice.
Thank you.
[EMAIL PROTECTED]
_______________________________________________
ActivePython mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/activepython