I'm trying to store the original filename, filetype, and filesize for an upload field using a smartgrid.
I can add these fields during the insert (by setting the field defaults) but not update the fields if you update the uploaded file. The edit form does upload the new file but I don't know how to then update the stored attributes. The upload field, request.vars.survey, initially contains the cgi.FieldStorage object during insert (from the new form). However, the edit form then contains the string for the new filename in request.vars.survey unless their is a new file submitted. But I don't know how to update the stored file attributes for the form before the smartgrid processes the updated upload file. db.define_table('person', Field('first_name'), Field('last_name'), auth.signature, format = '%(first_name)s %(last_name)s' ) db.define_table('contracts', Field('person', 'reference person'), Field('survey_filename', writable=False), Field('survey_filetype', writable=False), Field('survey_filesize', 'integer', writable=False), Field('survey', 'upload', autodelete=True), Field('description'), auth.signature ) def index(): if request.vars.survey != None and not type(request.vars.survey) is str: db.contracts.survey_filename.default = request.vars.survey.filename db.contracts.survey_filesize.default = request.env.content_length db.contracts.survey_filetype.default = request.vars.survey.filename.split('.')[-1] grid=SQLFORM.smartgrid(db.person) return dict(grid=grid) -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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/d/optout.