I want to convert image to base64 before sedig to server. how to do it in jquery?
html:
<input id="imgFld" type="file" accept="image/*;capture=camera" style="display:block;"/>
<input type="submit" id="submitImage" name=submit/>
js:
$(document).ready(function(){
alert("hello");
$("#submitImage").on('click',function(e){
e.preventDefault();
var ext = $('#imgFld').val().split('.').pop().toLowerCase();
if($.inArray(ext, ['gif','png','jpg','jpeg']) == -1) {
alert('Invalid extension!, Please choose the right extension - gif, jpg/jpeg or png');
}
else{
//covert to base64 and send ajax post
}
});