1
Posted on 7:40 AM by Softminer and filed under ,

Here is a simple example of reading file using javascript, more info on links
+
+
+

<input type="file" id="fileinput" />
<script type="text/javascript">
  function readSingleFile(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;
        alert( "Got the file.n" 
              +"name: " + f.name + "n"
              +"type: " + f.type + "n"
              +"size: " + f.size + " bytesn"
              + "starts with: " + contents.substr(1, contents.indexOf("n"))
        );  
      }
      r.readAsText(f);
    } else { 
      alert("Failed to load file");
    }
  }

  document.getElementById('fileinput').addEventListener('change', readSingleFile, false);
</script>
1
Response to ... Read Text Files Using the JavaScript FileReader
Unknown said... May 3, 2018 at 2:09 AM

Informative blog .. Thnq you for sharing..

Selenium training | Selenium training in chennai