JSFiddle - React, Tailwind, and code Playground
HTML
<input class="input-file" type="file" />
JavaScript
$(document).on("change", ".input-file[type=file]", function () {
var file = this.files[0];
alert(file.size);
if (file.size > 1024) {
alert("Too large Image. Only image smaller than 1K can be uploaded.");
$(this).replaceWith('<input class="input-file" type="file">');
return false;
}
});