JSFiddle - React, Tailwind, and code Playground
by Roger Ramos
HTML
<input type="file"/>
<img id="testImg" src="#" alt="your image" />
CSS
#testImg{position:absolute;left=-9999px;top:-9999px}
JavaScript
function getImgSize(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#testImg').attr('src', e.target.result);
}
reader.readAsDataURL(input.files[0]);
}
}
$('#testImg').on('load',function(){
alert($(this).width()+'*'+$(this).height());
})
$("input").change(function(){
getImgSize(this);
});