On Tuesday, August 13, 2013 9:20:47 AM UTC-4, at wrote:

>
> Here is my controller code:
> def test_upload:
>     if request.vars.file1 is not None:
>        result = db(db.mytable.id
> ==24).update(file1=request.vars.file1.file)
>

request.vars.file1 is a cgi.FieldStorage object. The original filename is 
therefore in request.vars.file1.filename. request.vars.file1.file is a 
temporary file on the filesystem, and it does not contain the original 
filename (instead, it has a temporary filename with no extension). If you 
want to manually insert an uploaded file, you should pass the 
cgi.FieldStorage object to the .insert() or .update() method rather than 
passing only the .file object from it. So, should be:

db(db.mytable.id==24).update(file1=request.vars.file1)

which is equivalent to calling:

db(db.mytable.id==24).update(file1=db.mytable.file1.store(request.vars.file1
)) 

Anthony

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to