11
I am developing a system in web2py and I have the following doubt:
I made a custom form that has a field that sends an image with preview. The code is like this:
{{=data['form'].custom.begin}}
{{dsp = data['form'].custom.dspval}}
{{inp = data['form'].custom.inpval}}
{{lbl = data['form'].custom.label}}
{{wid = data['form'].custom.widget}}
.
.
.
{{=B(lbl.logo)}}
{{=wid.logo}}
{{if inp.logo != '':}}
<br /><img src="{{=URL('static', 'upload/empresa/logo/'+inp.logo)}}" width="120" />
{{pass}}
.
.
.
{{=data['form'].custom.end}}
db.py is like this:
.
.
Field('logo',
label='Logo',
type="upload",
uploadfolder=os.path.join(request.folder,'static/upload/empresa/logo'),
autodelete=True
),
.
.
When processing the form, web2py does not update the value of inp.logo
, only when I re-load the view.
The wid.logo
brings the input, so it does not serve as a preview of the image. How should I reload the inp.logo
?
Just to better understand: you want the user to click the image upload field, choose the image, and it will appear immediately, without having to refresh the page?
– rafaels88