Is it possible to open a local file from a local page using FileReader without the <input type=file id=files>
The file is in the same directory as the page on a local machine.
reader = new FileReader();
reader.readAsText("output_log.txt");
Is it possible to open a local file from a local page using FileReader without the <input type=file id=files>
The file is in the same directory as the page on a local machine.
reader = new FileReader();
reader.readAsText("output_log.txt");
 
    
    I have created a sample code using Jquery/javascript which will read a local text file and display its content in Html page
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
$("#fileinput").on('change',function(evt){
    //Retrieve the first (and only!) File from the FileList object
    var f = evt.target.files[0]; 
    if (f) {
      var r = new FileReader();
      r.onload = function(e) { 
          var contents = e.target.result;
        $("#filename").html(f.name);
        $("#fileType").html(f.type);
        $("#display_file_content").html(contents);
      }
      r.readAsText(f);
    } else { 
      alert("Failed to load file");
    } 
});
});
</script>
</head>
<body>
<label>Please upLoad a file</label>
<input type="file" id="fileinput" />
</br>
<div>
<b>File Name:-</b><label id="filename"></label> </br>
<b>File Type:-</b><label id="fileType"></label></br>
<b>Content<b/>
<pre id="display_file_content">
</pre>
<div>
</body>
</html>
