[mod_python] How to do file uploads

Jonathan Frankel wikiterra at gmail.com
Tue Aug 21 18:24:48 EDT 2007


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


More information about the Mod_python mailing list