You can read files on the client using HTML5’s FileReader. The following example reads a text file on the client.
Your example attempts to use fopen which is not available in Javascript.
http://jsfiddle.net/k3j48zmt/
document.getElementById('file').addEventListener('change', readFile, false);
function readFile(evt) {
var files = evt.target.files;
var file = files[0];
var reader = new FileReader();
reader.onload = function(event) {
console.log(event.target.result);
}
reader.readAsText(file)
}
<input id=file type=file />