function list2script(ls) { } let upld = document.getElementById("listjson"); upld.onchange = function(event) { var fileList = upld.files; //TODO do something with fileList. var reader = new FileReader(); reader.addEventListener('load', function (e) { content = e.target.result; list2script(content); }); reader.readAsBinaryString(fileList[0]); }