Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js upload 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 :: orthographic camera three js 
Javascript :: form confirm before submit 
Javascript :: uuid v4 
Javascript :: onload set scroll on top of page jquery 
Javascript :: express draft 
Javascript :: on load of jquery 
Javascript :: sticky operations in javascript 
Javascript :: match date regex 
Javascript :: mysql json change key 
Javascript :: next day javascript 
Javascript :: jquery delay to call function 
Javascript :: how to create a .js file in windows command prompt code 
Javascript :: npm 
Javascript :: js encryption two way 
Javascript :: jquery enable textbox 
Javascript :: datatable without pagination 
Javascript :: convert object to json javascript 
Javascript :: items from first array that are not in the second array javascript 
Javascript :: timestamp js 
Javascript :: prevent form from reloading with preventDefault 
Javascript :: jquery event source 
Javascript :: javascript order by string array 
Javascript :: check if number is negative javascript 
Javascript :: Check if local storage is used or empty 
Javascript :: go to new page javascript 
Javascript :: get first two letter of an array javascript 
Javascript :: react js router parameters 
Javascript :: if statement es6 
Javascript :: center an element react native 
Javascript :: react get current date yyyy-mm-dd 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =