Actually this would work but it is not the best way, ... the problem is that the storage is already performed by accepts so you must do simply
file_form.accepts(request.vars,formname='file_form',onvalidation=check_file_in): db.srcfile.insert(name=form.vars.name) On Jun 15, 10:44 pm, mdipierro <mdipie...@cs.depaul.edu> wrote: > May be a bug. can you try? > > file_form.accepts(request.vars,formname='file_form',onvalidation=check_file_in): > request.vars.name.file.seek(0) ### add this line > db.srcfile.insert( > name=db.srcfile.name.store( > request.vars.name.file,request.vars.name.filename), > ) > > On Jun 15, 11:02 am, weheh <richard_gor...@verizon.net> wrote: > > > # model > > db.define_table('srcfile', > > Field('name','upload',length=50,label=T('Upload > > file'),autodelete=True, > > uploadseparate=True, > > requires=( > > IS_UPLOAD_FILENAME(extension='pdf|txt|doc|htm|html|xml|ppt'), > > IS_LENGTH(5000000,10)) > > ), > > ) > > > # controller > > ... > > file_form=SQLFORM.factory(db.auth_user,db.othertable,db.srcfile) > > ... > > if > > file_form.accepts(request.vars,formname='file_form',onvalidation=check_file_in): > > db.srcfile.insert( > > name=db.srcfile.name.store( > > request.vars.name.file,request.vars.name.filename), > > ) > > ... > > > Problem is, file gets uploaded into > > no_table.name/a2/ > > no_table.name.a24060930d31d0c1.313234363931322e747874.txt > > prior to the insert. After the insert, there is a folder > > srcfile.name/b1/srcfile.name.b192a5e35dc5081e. > > 313234363931322e747874.txt > > except that the file is empty. > > > Question: is this a bug, or do I need to explicitly copy from the > > source to the destination? If the latter, what would the rationale be > > for creating the destination file without copying the contents from > > the source?