Problems with CGI, genCGI and a multipart form

peter_carl at my-deja.com peter_carl at my-deja.com
Thu Jun 17 19:08:22 EDT 1999


I'm having trouble getting cgi.FieldStorage to read data posted as
multipart/form-data.

Right now I am testing a script using stdin piped from a test file.  The
test file has everything after the header from a posted form, e.g.,:

    -----------------------------172981055621895
    Content-Disposition: form-data; name="section"

    production
    -----------------------------172981055621895
    Content-Disposition: form-data; name="title"

    This is the title

etc...

Environment variables for Content-type, Content-Length, and
REQUEST_METHOD (POST) are set correctly.

When the script is run, cgi.FieldStorage is called with stdin to
populate self.formdict, but the results are always empty...

A similar script that is not a multipart POST (just a standard POST)
works fine, where stdin is:
MessageType=Suggestion&Subject=Web+Site&SubjectOther=&Comments=&UserName
=&UserEmail=&UserTel=&UserFAX=

Am I missing an environment variable?  Is there a trick I'm missing?

I've tried including the header; not including the header; and other
variations on the test input.

Help!

Thanks in advance,

pcc


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.




More information about the Python-list mailing list