title: How do you read a local file on your PC and update it constantly in javascript?
body: <p>So, I've made a <code>java</code> program that runs through a list of <code>IPs</code>, pings them, and updates a file on the devices status. I want to know how to open the file into a <code>webpage</code> and update it, so a user can open the webpage and just see a list of data from the file, they don't have to select the file or refresh the page.</p>
  
  <p>Is this feasible to do with <code>javascript/html</code>?</p>
  
  <p>This is the code I'm working with so far:</p>
  
  <pre><code>    &lt;html&gt;
      &lt;head&gt;
      &lt;title&gt;Import Data&lt;/title&gt;
      &lt;script&gt;
  
          var openFile = function() {
              var input = event.target;
  
              var reader = new FileReader();
              reader.onload = function() {
                  var text = reader.result;
                  var node = document.getElementById('output');
                  node.innerText = text;
                  console.log(reader.result.substring(0,200));
              };
  
              reader.readAsText(input.files[0]);
              setTimeout(openFile(),1000);
          };
      &lt;/script&gt;
      &lt;/head&gt;
      &lt;body&gt;
      &lt;input type='file' accept='text/plain' onchange='openFile()'&gt;&lt;br&gt;
      &lt;div id='output'&gt;
      &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>
  
  <p>But I can't seem to hunt down where to hardcode the path to the file in. When I use this manual selection method, it'll update once, whether the file increases in elements or decreases.</p>
  
  <p>EDIT:</p>
  
  <p>I've narrowed it down to where the file needs to be uploaded:</p>
  
  <pre><code>    &lt;html&gt;
         &lt;head&gt;
         &lt;title&gt;&lt;/title&gt;
         &lt;script&gt;
         function uploadFile() {
             var reader = new FileReader();
             reader.onload = function(event) {
                var contents = event.target.result;
                console.log("File contents: " + contents);
             };
  
             reader.onerror = function(event) {
                console.error("File could not be read! Code: " + event.target.error.code);
             };
  
             var fileInputElement = document.getElementById("FileName");
             reader.readAsText(fileInputElement.files[0]);
             console.log(fileInputElement.files[0]);
          }
          &lt;/script&gt;
          &lt;/head&gt;
          &lt;body&gt;
          &lt;input type='file' accept='text/plain' value='RESULTS.txt' id='FileName' onchange='uploadFile()' style="display:none;"&gt;
          &lt;/body&gt;
       &lt;/html&gt;
  </code></pre>
  
  <p>If I try to type just a file path in a string, it complains it's not type 'blob'. When I do this, it requires the user to enter a file name, but obviously it can't be seen. How can I make that 'file' variable a static variable so it always opens a that file without prompting the user?</p>