Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js open file dialog

var input = document.createElement('input');
input.style.visibility = 'hidden';
input.type = 'file';

input.onchange = e => { 

   // getting a hold of the file reference
   var file = e.target.files[0]; 

   // setting up the reader
   var reader = new FileReader();
   reader.readAsText(file,'UTF-8');

   // here we tell the reader what to do when it's done reading...
   reader.onload = readerEvent => {
      var content = readerEvent.target.result; // this is the content!
      console.log( content );
   }

}

input.click();
Comment

PREVIOUS NEXT
Code Example
Javascript :: get value of span jquery 
Javascript :: how to set background automatically with my screen height 
Javascript :: An accessor cannot be declared in an ambient context. 
Javascript :: req.body empty mongodb 
Javascript :: access url query string from javascript 
Javascript :: datatables ajax reload 
Javascript :: how to add sticky function in javascript 
Javascript :: add search query in express 
Javascript :: textbox text change jquery 
Javascript :: nodejs increase heap size 
Javascript :: socket.io.js file download 
Javascript :: javascript startswith 
Javascript :: how to start json server 
Javascript :: scroll back to top on every transition in react 
Javascript :: shadow border react native 
Javascript :: split string into equal chunks javascript 
Javascript :: js to json 
Javascript :: Get full year from date object 
Javascript :: javascript get timestamp 
Javascript :: radio button default checked react 
Javascript :: injected stylesheet remove 
Javascript :: scale text in div react 
Javascript :: refresh a page in jquery 
Javascript :: javascript replace string at position 
Javascript :: redirect browser javascript 
Javascript :: js object contain key 
Javascript :: cypress support ability to set viewport in `before` 
Javascript :: javascript for loops in vs of 
Javascript :: javascript check radio button 
Javascript :: json schema array of objects 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =