Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js upload json

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 :: react native flatlist pull to refresh 
Javascript :: javascript wait 10 seconds 
Javascript :: socket io broadcast to room 
Javascript :: jquery right click 
Javascript :: how to get data from user in javascript 
Javascript :: js vanilla when i remove one object it removes all of them 
Javascript :: fakepath 
Javascript :: jquery all elements whose id contains 
Javascript :: remove prefix js 
Javascript :: argument vs parameter javascript 
Javascript :: javascript to convert rgb to hsl 
Javascript :: jquery add td to tr dynamically 
Javascript :: angular formarray remove all 
Javascript :: js arrotondare numeri 
Javascript :: javascript regex replace all 
Javascript :: change text of span js html 
Javascript :: jquery first child 
Javascript :: ngrok angular 8 
Javascript :: corresponding text to key code js 
Javascript :: replace all spaces with dash in javascript 
Javascript :: this.$router.push nuxt 
Javascript :: mysql json change key 
Javascript :: Access data out of Axios .then vue.js 
Javascript :: npm 
Javascript :: mongoose.connect localhost 
Javascript :: javascript check if not null 
Javascript :: js add css class to element 
Javascript :: activeClassName in next.js 
Javascript :: how to keep scrolling with javascript 
Javascript :: 413 payload too large nodejs 
ADD CONTENT
Topic
Content
Source link
Name
8+1 =