function onSendImage() {
var img = document.createElement('img');
img.id = "img";
img.src = pathPhoto;
img.style.width = "100%";
img.style.height = "100%";
img.onload = function() {
getBase64Image(img);
}
document.body.appendChild(img);
}
function getBase64Image(img) {
var base64, base;
var canvas = document.createElement("canvas");
canvas.width = img.width;
canvas.height = img.height;
var ctx = canvas.getContext("2d");
ctx.drawImage(img, 0, 0, img.width, img.height);
base = canvas.toDataURL("image/png");
base64 = base.toString().substr(base.toString().indexOf(",") + 1);
}