[mod_python] upload pop-up

Jim Gallacher jg.lists at sympatico.ca
Mon Oct 17 20:00:25 EDT 2005

WR - wrote:
> The output that I get from my form is:
> Field('file', 'TESTTESTTEST')
> is the result of print file.
> When i'm going to use read() it not works because it is not a
> textfile but a Field with ('file', 'TESTTESTTEST').
> How can i change my form or script to only get TESTTEST......
> So i can write it to a new file.
> I show all my files in the mailing-list, thats all:
> http://www.modpython.org/pipermail/mod_python/2005-October/019299.html

Check the docs for the Field class.

Field instances have the following attributes:


     This is a file object. For file uploads it points to a temporary 
file. For simple values, it is a StringIO object, so you can read simple 
string values via this attribute instead of using the value attribute as 

Something like the following will work:

def index(req):
     uploaded_file = req.form['file']
     data = uploaded_file.file.read()
     return data


More information about the Mod_python mailing list