hi,

i would do the follow:

1) in model use compute to create image form base64 string:
db.define_table('user_images',
    Field('my_image', 'upload', label=T('My Image'), compute=lambda r: 
create_image_from_base64_str(r.my_image_b64)),
    Field('my_image_b64', 'text')
)

def create_image_from_base65_str(r):
...

    return filename


2) in controller:

form = SQLFORM(db.user_images)

if form.process().accepted:
    #form processed with no errors
    #image is created
    #make redirect
    redirect(URL('xyz', args=[form.vars.id]), client_side=True)   
...

3) in view i would use form.custom to create form with hidden fields and 
fake button. with js i would save the base64 string in the hidden field and 
do form.submit()



Am Montag, 7. April 2014 00:46:11 UTC+2 schrieb Ari Lion BR Sp:
>
> Any answer? I have the very same need. 
>

> Thanks 
> Ari
>
> Em segunda-feira, 2 de dezembro de 2013 14h02min30s UTC-2, Michael Hall 
> escreveu:
>>
>> If I have the following model:
>>
>> db.define_table('user_images',
>>     Field('my_image', 'upload',
>>           label=T('My Image')),
>> )
>>
>> and In my rendered html view I have a canvas, the canvas has produced an 
>> image saved in the variable 
>> document.getElementById('canvas').src = dataURL;
>>
>> Underneath the image is an upload button, I wish to POST the canvas image 
>> to user_images.myimage when the button is pressed and then move to a new 
>> view and controller which displays the uploaded image and has some more 
>> editing options.
>>
>> What is the best way to achieve this? Is it possible to render a sqlform 
>> that only has a button which when pressed uploads dataURL and redirects to 
>> the next controller/view?
>>
>>
>>

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to