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 :: get everything after the first character javascript 
Javascript :: javascript copy an object without reference 
Javascript :: react native go to next text input 
Javascript :: array differenc javascript 
Javascript :: vedere se radio button è cliccato js 
Javascript :: bright red in javascript 
Javascript :: fakepath js 
Javascript :: React Native - navigation is undefined 
Javascript :: new fabric canvas set width 
Javascript :: how to remove 000webhost watermark 2019 
Javascript :: datatable columns with nullable fields ajax 
Javascript :: javascript to string 
Javascript :: get docs with date intervals mongoose 
Javascript :: standalone form inside reactive form 
Javascript :: email validation in react js 
Javascript :: npm proxy config 
Javascript :: jquery on load button click 
Javascript :: find particular object from array in js 
Javascript :: video js toggle play pause 
Javascript :: js array to object with keys 
Javascript :: Jquery get value of dropdown selected 
Javascript :: how to set validation for email in javascript 
Javascript :: javascript get first letter of each word 
Javascript :: Format number thousands k javascript 
Javascript :: mongoose.connect 
Javascript :: hide div js 
Javascript :: js append class 
Javascript :: next js active nav link 
Javascript :: sweetalert angular 8 
Javascript :: change mouse highlight color js 
ADD CONTENT
Topic
Content
Source link
Name
6+6 =