Get filename after filereader asynchronously loaded a file

前端 未结 2 1969
一向
一向 2020-12-14 00:34

I am loading several files in a directory in order to parse some data from them. This works great so far, but I would like to know which file I am looking at. So I need the

2条回答
  •  独厮守ぢ
    2020-12-14 01:04

    Create a closure around the File to capture the current file. Then you can get the filename.

    An example: http://www.html5rocks.com/en/tutorials/file/dndfiles/#toc-reading-files

    Closure to capture the file information.

    function parseData(entries){
      for (var i=0; i

    And the called function gets an additional argument

    function createListItem(evt, file) {
      console.log(evt.target.result)
      console.log(file.name);
    }
    

提交回复
热议问题