As pointed in the comments, file
is a blob
:
file instanceof Blob; // true
And you can get its content with the file reader API https://developer.mozilla.org/en/docs/Web/API/FileReader
Read more: https://developer.mozilla.org/en-US/docs/Using_files_from_web_applications
var input = document.querySelector('input[type=file]');
var textarea = document.querySelector('textarea');
function readFile(event) {
textarea.textContent = event.target.result;
console.log(event.target.result);
}
function changeFile() {
var file = input.files[0];
var reader = new FileReader();
reader.addEventListener('load', readFile);
reader.readAsText(file);
}
input.addEventListener('change', changeFile);
<input type="file">
<textarea rows="10" cols="50"></textarea>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…