title: read multiple file inputs
body: <p>This is the code I have for reading the first item in a file input, how can I iterate over all items inside this input? </p>
  
  <pre><code>function readFile (uploadControlId) {
      if (!window.FileReader)
          throw "The browser does not support HTML 5";
  
      var element = document.getElementById(uploadControlId);
  
      var def = new $.Deferred();
  
      var file = element.files[0];
      var parts = element.value.split("\\");
      var fileName = parts[parts.length - 1];
  
      var reader = new FileReader();
      reader.onload = function (e) {
          if (uploadControlId == 'uploadControlId'){
              def.resolve(e.target.result, fileName);
          } else {
              def.resolve(e.target.result, fileName);
          }
  
      };
      reader.onerror = function (e) {
          def.reject(e.target.error);
      };
  
      reader.readAsArrayBuffer(file);
      return def.promise();
  }
  </code></pre>
  
  <p>I have tried something like:</p>
  
  <pre><code>angular.forEach(element.files, function (file){
  })
  </code></pre>
  
  <p>But this doesn't work since the variables 'parts' and 'fileName' is from the variable 'element', so if I iterate over  each file in element, they get 'undefined' fileName, this means  they won't have like .txt or .pdf, so they are unreadable.</p>
  
  <p>Update: This give no error, but only the last file gets uploaded:</p>
  
  <pre><code>    function readFile (uploadControlId) {
      if (!window.FileReader)
          throw "The browser does not support HTML 5";
  
      var def = new $.Deferred();
  
      var element = document.getElementById(uploadControlId);
  
      angular.forEach(element.files, function(file){
  
          var fileName = file.name;
  
          var reader = new FileReader();
          reader.onload = function (e) {
              def.resolve(e.target.result, fileName);
          };
          reader.onerror = function (e) {
              def.reject(e.target.error);
          };
  
          reader.readAsArrayBuffer(file);
      });
      return def.promise();
  }
  </code></pre>
  
  <p>My upload function: </p>
  
  <pre><code>$scope.UploadAttachment = function(){
      readFile(uploadControlId).done(function (buffer, fileName) {
  
  // logic to upload to server
  
      }).fail(function (err) {
          alert("error in reading file content");
      });
  
  };
  </code></pre>