I am distributing my images converted to base64 and then crop them, but when I run the function my variablechosenImage, she goes undefined in the onload but is well defined just before (observation made thanks to the debugger). Would you have a solution to solve my problem? I've already tried passing the variable to var to make it global, but no effect.
Here is my code :
let reader = new FileReader();
let uploadButton = document.getElementById("upload-button");
file_recup = document.getElementById("upload-button").value;
var chosenImage = document.getElementById("img_crop_1");
reader.readAsDataURL(uploadButton.files[0]);
reader.onload = () => {
chosenImage.src = reader.result;
}