[Twisted-web] twisted-web file upload processing on the server

Matthew Thorley ruach at chpc.utah.edu
Tue Dec 13 13:07:47 MST 2005

Please forgive me if this is obvious, but I couldn't find the answer
any where! I searched google, the new twisted book, the twisted-web
docs, and the mailing list archive. I saw other posts with similar
questions but not the answer, so here goes.

I'm using twisted version 2.1.0 and I did the sumo download to make it
easy on myself

I've got a setup like this on the server:

class UploadPage(resource.Resource):
   def render_POST(self, request):
       filename = request.args['cml'][0]
       # filecontent = ???
       return "You uploaded file: %s" %filename

And I'm using a form like this to send the file:

<form enctype="mulitpart/form-data" action="/upload"
    <p>CML: <input name="cml" type="file"/></p>
    <p><input type="submit" name="submit" value="Upload"/></p>

When I upload the file everything works and the correct file name
shows in the output. But what I can't do is read/get the contents of
the file.

Can some one please explain how to do server side file upoad
processing??? I'm totaly lost here. I'm sure that it must be something
painfully obvious, since uploads are such a common thing. But I can't
figure it out.

Thanks much
Matthew Thorley

More information about the Twisted-web mailing list