htmlinputfile
var fileInput = document.getElementById("fileUpload");
fileInput.addEventListener('change'
function() {
var file = this.files[0];
var reader = new FileReader();
reader.onload = function(e) {
var contents = e.target.result;
var words = contents.split(" ");
var wordCount = words.length;
if(wordCount >= 1000) {
console.log("Text contains 1000 or more words");
} else {
console.log("Text contains less than 1000 words");
}
};
reader.readAsText(file);
});
版权声明:本站内容源自互联网,如有内容侵犯了你的权益,请联系删除相关内容。