| Gregory (Grisha) Trubetskoy 
    grisha at modpython.org Thu Sep 18 11:09:25 EST 2003 
 On Wed, 17 Sep 2003, Greenbeard wrote: > Does anyone have a good file upload example? > > When I try something like: > > def upload(req, file): > tempFile = file.read() I think it should be file.file.read(). You also may want to make sure that it's a file upload first - you can do this by testing for existance of a filename attribute, e.g. hasattr(file, "filename), or, more accurately, you can make sure it's an instance of util.Field: if isinstance(file, util.Field): data = file.file.read() else: return "This is not a file" Grisha 
 |