This should do it but I have not tried it db.define_table('image',Field('data','upload'),Field ('size','integer'))
def store_size(form): request.vars.image.file.seek(0) form.vars.size=len(request.vars.image.file.read()) form=SQLFORM(db.image) form.accept(request.vars,session,onvalidation=store_size) On Jul 15, 6:11 pm, Richard <richar...@gmail.com> wrote: > hello, > > I want to store the actual length of each uploaded file in my table. > I've seen around the forum people using request.env.content_length for > that. > Is there an alternative interface to that information? > > Richard > > On Jul 15, 11:44 pm, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > No there s no problem with this. You should not determine the size of > > the file with request.env.content_length, you should use > > > ... Field('name','upload',requires=IS_LENGTH(10000)) > > > where 10000 is the max lenght. > > > On Jul 15, 7:06 am, Richard <richar...@gmail.com> wrote: > > > > hello, > > > > the current database design of our application will require the user > > > to upload 2 files in a single form. Is there any problem with this? > > > One thing I thought of is we could no longer determine the size of the > > > file with request.env.content_length. > > > > Richard --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---