I want an onload alert to show my file names from a hard drive. I had a previous question about reading files on a hard drive (Javascript to read other files in hard drive?) and with the help of Ozan Deniz's comment about a File Reader (Reading client side text file using Javascript), I figured out what will work but I needed a list of files first. So, using command line I populated a text file using
Command Line
dir/b * > files.txt
but I cannot get the readFile function to work correctly. I get the error "Failed to execute 'readAsText' on 'FileReader': The argument is not a Blob." with the following code:
Javascript
<script>
//document.getElementById('file').addEventListener('click', readFile, false);
function readFile () {
var files = document.getElementById('file');//evt.target.files;
var file = files[0];
var reader = new FileReader();
reader.onload = function() {
alert(this.result);
}
reader.readAsText(file)
}
readFile();
</script>
HTML
<a href='files.txt' id='file'>Files</a>