JSFiddle - React, Tailwind, and code Playground

by Subhasish2015

HTML

<!doctype html>
<html>
    <body>
            <input type="file" id="fileBut" />
            <button id="killBut">revoke URL</button>
    </body>
</html>

JavaScript

var fileBut = document.getElementById("fileBut");
var killBut = document.getElementById("killBut");
window.URL = window.URL || window.webkitURL;
var ourURL;

fileBut.onchange = function () {
    var img = document.createElement("img");
    img.onload = function () {
        document.body.appendChild(img);
    };
    ourURL  = URL.createObjectURL (this.files[0]);
    img.src = ourURL;
};

killBut.onclick = function () {
    URL.revokeObjectURL(ourURL);
    fileBut.value = '';
};