title: convert HTML file contents into a string in Javascript
body: <p>I'm asking users to upload and HTML file, I would like to convert the contents of the HTML file into a string.</p>
  <p>HTML file:</p>
  <pre class="lang-html prettyprint-override"><code>&lt;form action=&quot;&quot;&gt;
    &lt;input type=&quot;file&quot; name=&quot;pic&quot; accept=&quot;html&quot; id = &quot;htmlFile&quot;&gt;
  &lt;/form&gt;
  </code></pre>
  <p><strong>JAVASCRIPT</strong></p>
  <pre><code>function readTextFile(file) //this is all wrong I think
  {
      var rawFile = new XMLHttpRequest();
      rawFile.open(&quot;GET&quot;, file, false);
      rawFile.onreadystatechange = function ()
      {
          if(rawFile.readyState === 4)
          {
              if(rawFile.status === 200 || rawFile.status == 0)
              {
                  var allText = rawFile.responseText;
                  alert(allText);
              }
          }
      }
      rawFile.send(null);
  }
  </code></pre>