JSFiddle - React, Tailwind, and code Playground

HTML

<h1>Test</h1>
<input type="file" id="input"/>
<canvas width="400" height="300" id="canvas"/>

JavaScript

var input = document.getElementById('input');
input.addEventListener('change', handleFiles);

function handleFiles(e) {
    var ctx = document.getElementById('canvas').getContext('2d');
    var img = new Image;
    img.src = URL.createObjectURL(e.target.files[0]);
    img.onload = function() {
        ctx.drawImage(img, 20,20);
        alert('the image is drawn');
    }
}