i think it's dillema in here if request.vars.image != None: # this work when the image is there, can't work if the image is empty (leave blank), it return an error traceback said : AttributeError: 'str' object has no attribute 'filename'
if request.vars.image: # this work when the image is blank, but when you upload the file in image, the image_filename is empty / None tested in web2py recent version def create(table, fields, redirect): form = SQLFORM(table, fields = fields) #if current.request.vars.attachment: if current.request.vars.attachment != None: form.vars.attachment_filename = current.request.vars.attachment.filename if form.process().accepted: current.response.flash = 'Form accepted' #redirect(URL(redirect) ) elif form.errors: current.response.flash = 'Form has errors' else: current.response.flash = 'Please fill out the form' return dict(form = form) -- 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.