<input type="file"> <script> var arr; document.querySelector('input').onchange = function(){ var fr = new FileReader(); fr.onload = function(){ arr=this.result.split(' '); }; fr.readAsText(this.files[0]); }; </script>