JSFiddle - React, Tailwind, and code Playground
HTML
<input type="file" id="fileInput" />
<input type="button" onClick="checkDeleted();" value="Check" />
JavaScript
function checkDeleted() {
input = document.getElementById('fileInput');
if (input.files.length > 0) {
var file = input.files[0];
var fr = new FileReader();
fr.onload = function (e) {
alert("File is readable");
};
fr.onerror = function (e) {
if (e.target.error.name == "NotFoundError") {
alert("File deleted");
}
}
fr.readAsText(file);
} else {
// no file choosen yet
}
}