[mod_python] File upload

Greenbeard greenbeard400 at yahoo.com
Wed Sep 17 21:42:47 EST 2003


Does anyone have a good file upload example?  

When I try something like: 

def upload(req, file):
    tempFile = file.read()
 
I get: AttributeError: File instance has no attribute
'read'

if I use:

    tempFile = req.form['file'] 
I get the file contents but I don't think this would
work well with large files (or would it?) 

Also, 
 
when I try to get attribues like file.type I get 

AttributeError: File instance has no attribute 'type'.
I do get the file.filename.   

So how can I tell if it should be a binary write etc.?

It looks like the publisher handler (which I am using)
returns a File object but I can not get it to act like
a file/StringIO object nor can I accesss the
attributes that are mentioned in the documentation.   


I am using W2k, Python 2.2  and Mod_py 3.0.3.  

Thanks for the help,

gb400



__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com


More information about the Mod_python mailing list