javascript - Passing base64 encoded image through form -


i using image editing tool users upload images , adjust: http://foliotek.github.io/croppie/

i able shorten base64 string sending through couple functions. trying insert hidden field , submit form.

$('#submit-update-business').on('click', function(e){     e.preventdefault();     // console.log(vanilla.get());     vanilla.result('canvas', 'viewport', 'png', 0).then(function(src){         var processed = base64.encode(json.stringify(src));         $('#new_image').val(processed);         $('#update-business').submit();     }); }); 

i know string long, can't figure out other way this. i've seen answers suggest submitting form through ajax, seems have same pitfalls. manages work ok on desktop browsers. it's mobile ones have problem. can limit dimensions of image less 3000x3000, unfortunately phones seem taking higher quality photos.

the tool i'm using, croppie, has way data points , zoom, not orientation. if there way save data, or use base64 data, , re-render image, , somehow use image image goes through, great. if there solution can use mobile, work too, since works fine on desktop.

with ajax post instead of submit don't need hidden_field if has length limits in mobile browser. base64 encoding overhead not necessary if don't need on server side.

.post(   "/ajaxposturl.php",   {     new_image: processed, // or new_image: src,     other_form_param_or_data: 'some_data'   } ); 

Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -