HOW TO LOAD DATA FROM A FILE (E.G. SAVE.TXT) USING JAVASCRIPT - Part 2: Save / Load

Published: 03 March 2021
on channel: ZeroLife
2,943
65

HOW TO LOAD DATA FROM A FILE (E.G. SAVE.TXT) USING JAVASCRIPT
Part 2: Save / Load

HTML
-----------
(input type="file" onchange="loaddata(this)" /)


JAVASCRIPT
---------------------
function loaddata(e){

var file = e.files[0];
var reader = new FileReader();

reader.onloadend = function(){
var load = JSON.parse(reader.result);
console.log(load)
//Do something with load
};
reader.readAsText(file);

};

// ===== Alternative =========

function loaddata(){

var input = document.createElement('input');
input.setAttribute('type','file');
input.click();
input.onchange = function(e){
var file = e.files[0];
var reader = new FileReader();
reader.onloadend = function(){
var load = JSON.parse(reader.result);
console.log(load)
//Do something with load
};
reader.readAsText(file);
};
};
PAT:   / rezatahirkheli  
PP: https://www.paypal.com/paypalme/rezat...
BTC: 3EUQBWZKX9Vcwdffd3cUGATQopxrAQQxJ9
LTC: MBXE6hJgxxFYSD8SjmR7sHCHGTqFXmNGoU
GFM: https://gofund.me/7d6500bd


Watch video HOW TO LOAD DATA FROM A FILE (E.G. SAVE.TXT) USING JAVASCRIPT - Part 2: Save / Load online without registration, duration hours minute second in high quality. This video was added by user ZeroLife 03 March 2021, don't forget to share it with your friends and acquaintances, it has been viewed on our site 2,943 once and liked it 65 people.