title: Again: how can I read a file using javascript
body: <p>I could not find out why this part of my code doesn't work:</p>
  
  <pre><code>var loc = window.location.pathname;
  var dir = loc.substring(0, loc.lastIndexOf('/'));
  var FilePath = dir + "/" + FileName;
  var file = new File("FilePath");
  var reader = new FileReader();
  reader.onload = function(e) {FileText = reader.result;}
  reader.readAsText(file); 
  alert (FileText);
  </code></pre>
  
  <p>The intention is, I think, clear: FilePath contains the filename of a file  (passed via parameter FileName) containing logging data (a plain ASCII text file, with one line per log entry), the file is located in the same directory as the web page is (loc), and I want to embed the text into my html document somewhere further down the code. </p>
  
  <p>Since the logged lines are of different kinds (e.g. errors, warning, other blabla ...) each line needs to be parsed and processed. </p>
  
  <p>I intended to split FileText into an array, and loop through it. I cannot, however, get readastext to work. Though, according to FireFox debugger, FilePath does contain the correct string, I get the NS_ERROR_FAILURE, which I, according to the sparse documentation I found about it, must consider to be the 'zillionst stupid way to say "File not found".</p>
  
  <p>I found tons of other posts from people messing with the file API, and tons of snippets taken from the mozilla docs which don't help me out. I read that there are maybe other ways to read a file, e.g. through Ajax, JQuery ... but before I go that way ... is it really, really absolutely impossible to accomplish what I want using just plain JavaScript, and if it is possible, who can provide a code snippet?</p>
  
  <p>Thanks very much,</p>
  
  <p>Armin.</p>