File Uploads

and-google at doxdesk.com and-google at doxdesk.com
Mon Mar 28 00:42:59 EST 2005


Doug Helm wrote:

> form = cgi.FieldStorage()
>   if lobjUp.Save('filename', 'SomeFile.jpg'):

> class BLOB(staticobject.StaticObject):
>   def Save(self, pstrFormFieldName, pstrFilePathAndName):
>     form = cgi.FieldStorage()

You are instantiating cgi.FieldStorage twice. This won't work for POST
requests, because instantiating a FieldStorage reads the form data from
the standard input stream (the HTTP request).

Try to create a second one and cgi will try to read all the form data
again; this will hang, waiting for the socket to send it a load more
data which will not be forthcoming.

When using CGI, parse the input only once, then pass the results (a
FieldStorage object if you are using the cgi module) in to any other
functions that need to read it.

-- 
Andrew Clover
mailto:and at doxdesk.com
http://www.doxdesk.com/




More information about the Python-list mailing list