Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript json upload

function upload() {
    const input = document.createElement('input');
    input.style.visibility = 'hidden';
    input.type = 'file';
    input.onchange = e => { 
        // getting a hold of the file reference
        const file = e.target.files[0];
        // setting up the reader
        const reader = new FileReader();
        reader.readAsText(file,'UTF-8');
        // here we tell the reader what to do when it's done reading...
        reader.onload = readerEvent => {
            let content = readerEvent.target.result; // this is the content!
            try {
                // Try to read json
                // noinspection JSCheckFunctionSignatures
                objs = JSON.parse(content);
            } catch (e) {
                objs = {};
            }
        }
    }
    input.click();
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript find document body 
Javascript :: start peerjs server 
Javascript :: you have no internet connection angular 
Javascript :: Check your Homestead.yaml (or Homestead.json) file, the path to your private key does not exist. 
Javascript :: useeffect async not working 
Javascript :: lip. dips *dipped. also mm bpi. -opp. -ditty 
Javascript :: fakepath file show in html page in js 
Javascript :: javascript remove last child element 
Javascript :: loop json jquery 
Javascript :: nods js fs append to file 
Javascript :: jquery on click dynamic element 
Javascript :: jquery ajax delete 
Javascript :: hemisphere light three js 
Javascript :: adonis hook 
Javascript :: javascript loop over classes 
Javascript :: how do i get month and date of javascript in 2 digit format 
Javascript :: getServerSideProps cookie 
Javascript :: valid phone number regex with country code 
Javascript :: set a timer for 10 minutes 
Javascript :: useFetch custom hook for React 
Javascript :: json stringify indent 
Javascript :: textbox text change jquery 
Javascript :: js get the week monday to friday date 
Javascript :: how to start json server 
Javascript :: javascript round decimal 
Javascript :: uppercase and lowercase letters in js 
Javascript :: sequelize logging insert 
Javascript :: fetch data from api in react 
Javascript :: moment js convert to local timezone 
Javascript :: iterate array javascript 
ADD CONTENT
Topic
Content
Source link
Name
2+2 =