title: Pass a parameter to FileReader onload event
body: <p>I need to read some csv files, given by the user. Files are passed to the page/script using a drag and drop div, that handles the file drop as follows:</p>
  
  <pre><code>function handleFileDrop(evt) {
      evt.stopPropagation();
      evt.preventDefault();
      var files = evt.dataTransfer.files; // FileList object.
      ...
  }
  </code></pre>
  
  <p>I need to parse each file with a csv library that converts it into an array, but I also need to keep track of the file name I'm currently parsing. Here's the code I use to parse each file:</p>
  
  <pre><code>for(var x = 0; x &lt; files.length; x++){
      var currFile = files[x];
      var fileName = currFile.name;
      var reader = new FileReader();
      reader.onload = (function(theFile){
          return function(e){
              var csvArr = CSV.csvToArray( e.target.result, ";", true );
              console.log(csvArr); 
          };
      })(currFile);   
      reader.readAsText(currFile);
  }
  </code></pre>
  
  <p>Until this, everything works great. What I need is to also pass the filename to the <code>reader.onload</code> event, eg:</p>
  
  <pre><code>reader.onload = (function(theFile){
      return function(e){
  
         ***** I need to have fileName value HERE *****
  
      };
  })(currFile); 
  </code></pre>
  
  <p>Is possible? How can I do this? Thanks in advance for any help, best regards</p>