I have an file input and iI want to draw the selected filein a canvas.
Calling a function that draws the img works.
fileselect.addEventListener("change", () => {
if(fileselect.files[0].type === "image/png" || fileselect.files[0].type === "image/jpg"){
reader.readAsDataURL(fileselect.files[0])
console.log(reader)
}
});
reader.onload = () => {
img.src = reader.result
console.log(img)
ctx.drawImage(img, 0, 0);
};
btw. the console.log returns a correct base 64 string