Hello Alex, Two things I've found when manually uploading via SQLFORM.factory:
1) You need to specify a table_name='...' to avoid the no_table_newfilename.extension issue like this: form = SQLFORM.factory(...Field definitions..., table_name='some_table_name') 2) Additionally you must specify an uploadfolder in your upload Field definition similar to this: form = SQLFORM.factory(..., Field('invoice_logo', type='upload', uploadfolder=os.path.join(request.folder,'static/uploads/')), ..., table_name='whatever_you_like') **NOTE** 'static/uploads' is just an example, you can upload to wherever it will be appropriate. In this case the newly uploaded and renamed file to your_application's_dir/static/uploads/your_new_filename_here One gotcha to look out for following your field name as an example without the quotation marks: In your form.accepts(...): "request.vars.invoice_logo" will contain the original filename of your upload whereas "form.vars.invoice_logo_newfilename" will contain the newly renamed file like yourtablename.9203842903.thaoeu09gu023hgda3p.ext No need to call store() directly as SQLFORM.factory will take care of that for you. I hope that this helps you. -David Bloom On Oct 4, 7:53 pm, Alex <mrauc...@gmail.com> wrote: > Hi, > > I've already spent quite some time with the following problem which I > think should be fairly easy. I hope someone can help me. > > # model > db.define_table('admin_setting', > Field('name', 'string', notnull=True), > Field('value', 'string', notnull=True)) > > in the controller I'm creating a form for various admin settings. > form = SQLFORM.factory( > Field('invoice_logo', 'upload'), ...) > > the view works well and displays all fields. > > When uploading a file for the logo the file should be handled like > always (file uploaded to uploads folder, renamed to uuid filename). in > the table admin_setting I want to store the filename of the uploaded > file in a row where name='invoice_logo' (the filename should be stored > in the value field). > > How can I achieve this? currently I have this code (the update is > performed later and not shown here): > if form.accepts(request.vars, formname='admin_setting_form', > dbio=False): > if request.vars.invoice_logo != None: > if type(request.vars.invoice_logo) != str: > request.vars.invoice_logo_filename = > request.vars.invoice_logo.filename > field = Field('invoice_logo', 'upload') > # field.store fails because field does not have a _tablename > uploaded_file = field.store(request.vars.invoice_logo.file, > request.vars.invoice_logo.filename) > else: > del request.vars.invoice_logo # do not delete existing logo