javascript - Hardcode file path instead of manual file input -


i want read text file using javascript. passing filelist object, available codes use <input type="file"> change event, want path of txt file hardcoded inside javascript , event fired onload of document. how can implement it?? available code <input type="file"> is:

<input type="file" id="fileinput" /> <script type="text/javascript">   function readsinglefile(evt) {     //retrieve first (and only!) file filelist object     var f = evt.target.files[0];      console.log(evt);     if (f) {       var r = new filereader();       r.onload = function(e) {            var contents = e.target.result;         alert( "got file."+f);         }       r.readastext(f);     } else {        alert("failed load file");     }   }   document.getelementbyid('fileinput').addeventlistener('change', readsinglefile, false); </script> 

you can't. access files on user's system requires user picks them explicitly security measure.


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -