title: Read the content from text file using JavaScript
body: <p>I am trying to read a text file using JavaScript and display the content in html file.</p>
  <p>Its working as I have created the browse button to select the text file but I want to read the content from a fixed path file. In this program instead of taking the file path I want to read file from the path like - <code>D:/new folder/abc.text</code></p>
  <p>I am using the following code:</p>
  <pre><code> &lt;html&gt;
   &lt;input type=&quot;file&quot; id=&quot;fileinput&quot;/&gt;
   &lt;script type=&quot;text/javascript&quot;&gt;
   function readSingleFile(evt) {
   var f = evt.target.files[0]; 
   if (f) {
   var r = new FileReader();
   r.onload = function(e) { 
   var contents = e.target.result;
   document.write(&quot;the contents of the file are&lt;br&gt;&quot;);
   document.write(contents);
    }
     r.readAsText(f);
    } else { 
     alert(&quot;Failed to load file&quot;);
    }
   }
    document.getElementById('fileinput').addEventListener('change',readSingleFile,false);
    &lt;/script&gt;
     &lt;/html&gt;
  </code></pre>