JS FileReader: Read CSV from Local File & jquery-csv

后端 未结 2 1697
后悔当初
后悔当初 2021-01-13 02:46

I have a CSV file in the same directory as an html page, and I\'d like to use FileReader to read the file contents into a jquery-csv\'s To Arrays function, but I can\'t seem

2条回答
  •  猫巷女王i
    2021-01-13 03:28

    It's not going to work.You have no permissions to read files with javascript from the browser. The only way to deal with it is to create an input[type=file] tag and add onChange event to it. For example:

    document.getElementById('fileupload').addEventListener('change', function (e) {
      var files = e.target.files;
      //proceed your files here
      reader.readAsText(files[0]);
    }, false);
    

提交回复
热议问题