Hi *,
is there a way to modify the file name with whom a file is stored in the
filesystem using an upload field?
I tryied in this way but without success:
def upload_static_overlay_form_processing(form):
# here "form.vars.shp" contains the file object and
## "form.vars.shp.filename" is the original filename in my local
filesystem
filename = form.vars['shp'][:-4].replace('.', '_')
for h in shapeformat.extensions:
for i in shapeformat.extensions[h]:
form.vars[shapeformat.extensions[h][i]] = filename +
'.' + shapeformat.extensions[h][i]
def upload_static_overlay():
record = miscdb.shapelayers(request.args(0))
url = URL('download')
form = SQLFORM(miscdb.shapelayers,
record,
deletable=True,
upload=url)
if form.accepts(request.vars, session,
onvalidation=upload_static_overlay_form_processing):
response.flash = 'form accepted'
# here "form.vars.shp" contains the file name string created by
web2py
elif form.errors:
response.flash = 'form has errors'
return dict(form=form)
the problem is that in the validating function "form.vars.shp" contains
the file oblect uploaded and then, only after the validation, it
contains the file name string I need to modify, but at this point the
files are already uploaded and nothing can be done :(
thankyou very much for any suggestion
Manuele