title: HTML 5 File Reader reading javaScript files
body: <p>I'm trying to allow users to drag and drop a folder containing JavaScript files into an html5 page. This is what I currently have:</p>
  <pre><code>$scope.files = [];
  
  //Establish dropzone
  var dropbox;
  dropbox = document.getElementById(&quot;fileDragAndDrop&quot;);
  dropbox.addEventListener(&quot;dragenter&quot;, dragenter, false);
  dropbox.addEventListener(&quot;dragover&quot;, dragover, false);
  dropbox.addEventListener(&quot;drop&quot;, drop, false);
  
  //Events
  function dragenter(e) {
      e.stopPropagation();
      e.preventDefault();
  };
  function dragover(e) {
      e.stopPropagation();
      e.preventDefault();
  };
  function drop(e) {
      e.stopPropagation();
      e.preventDefault();
      
      var items = e.dataTransfer.items;
  
      for (var i = 0, item; item = items[i]; i ++) {
          var entry = item.webkitGetAsEntry();
          
          if(entry) {
              traverseFileTree(entry);
          }
      }
  };
  
  //resursive file walker
  function traverseFileTree(item) {
      if(item.isFile) {
           $scope.$apply(function () {
              $scope.files.push(item);
           });
      } else if (item.isDirectory) {
          var dirReader = item.createReader();
          dirReader.readEntries(function(entries) {
              for (var i = 0; i &lt; entries.length; i++) {
                  traverseFileTree(entries[i]);
              }
          });
      }
  };
  </code></pre>
  <p>So the dragging and dropping works, but I'm having problems reading the file content.</p>
  <pre><code>$scope.parse = function () {
      
      for(var i = 0; i &lt; $scope.files.length; i++) {
  
          var fileReader = new FileReader();
  
          fileReader.onload = function (e) {
          
              console.log(fileReader.result);
          };
  
          fileReader.onerror = function(err) {
              console.log(err);
          };
  
          fileReader.readAsBinaryString($scope.files[i]);
      }
  };
  </code></pre>
  <p>I am not getting any error messages, which makes it hard to debug. Am I doing something wrong? has anyone had any issues doing similar tasks?</p>