How can I convert the image to Base64 and send it via AJAX for processing without using any external library?
Simple HTML
<input type="file" id="image" accept="image/*">
AJAX
$(document).on('click', '.btn-report', function(e){
e.preventDefault();
var image = $("#image").val(); // I WANT TO CONVERT THIS INTO BASE64
$.ajax({
type: "POST",
url: "processes/report.php",
data: 'image='+image,
cache: false,
enctype: 'multipart/form-data',
beforeSend: function(){
$(".message").hide();
},
success: function(data){
$(".message").html(data).fadeIn();
$("html, body").animate({ scrollTop: 0 }, "slow");
}
});
});
Is it possible? If yes, how?