function posting() {
const canvas = document.getElementById('canvas');
const imgBase64 = canvas.toDataURL('image/jpeg', 'image/octet-stream');
const decodImg = atob(imgBase64.split(',')[1]);
let array = [];
for (let i = 0; i < decodImg .length; i++) {
array.push(decodImg .charCodeAt(i));
}
const file = new Blob([new Uint8Array(array)], {type: 'image/jpeg'});
const fileName = 'canvas_img_' + new Date().getMilliseconds() + '.jpg';
let formData = new FormData();
formData.append('file_give', file, fileName);
$.ajax({
type: "POST",
url: "/fileupload",
data: formData,
cache: false,
contentType: false,
processData: false,
success: function (response) {
alert(response["result"])
window.location.href = '/result'
}
});
}