[mod_python] How to do file uploads

Graham Dumpleton graham.dumpleton at gmail.com
Tue Aug 21 21:57:10 EDT 2007



req.form only exists if you are using publisher. If not using
publisher, add to start of handler the code:

  req.form = util.FieldStorage(req)

to create it.


On 22/08/07, Jonathan Frankel <wikiterra at gmail.com> wrote:
> Hello, I'm just using mod_python for the first time, and I'm trying to
> figure out how to do file uploads. However, I'm completely confused
> with this. From the documentation it seems to indicate that the best
> way to do it is to use the FieldStorage class...except I can't see how
> the examples provided have anything to do with file uploads.
> When I search around I find very little, though the popular method
> seems to be to use req.form['file'].file to return a file object.
> Except I can't find where the documentation says anything about a
> "form" attribute in req. Furthermore, I see people saying that it's
> best to pass the data from the client through an input filter, which
> sounds good and I kind of sort of get it, but don't know how to
> implement it and can't find any examples.
> Can anyone provide me with an example that allows a client to upload a
> file, and limits it to a certain size? I really think that this sort
> of thing should be provided as an example. If I get this working, I'll
> gladly donate my code to put up on the examples page.
> Thanks in advance,
> Jonathan
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python

More information about the Mod_python mailing list