JSFiddle - React, Tailwind, and code Playground

by Suratin Pattanawongthai

HTML

<form action="upload.php" enctype="multipart/form-data" method="POST" id="uploadform">
    <input id="openFile" name="img" type="file" />
</form>

JavaScript

$(document).ready(function () {
    $('#openFile').on('change', function (evt) {
        
        fr = new FileReader();
        fr.readAsDataURL($(this)[0].files[0]);
        fr.onload = function(file){
            console.log(file);
        }
    });
});