title: Unable to read and upload file using FileReader object in Lightning component
body: <p>I am trying to upload a file into Salesforce using the Lightning input component:</p>
  
  <p><strong>Component</strong></p>
  
  <pre><code>&lt;aura:component controller="FileUploadController"&gt;
  
  &lt;lightning:input 
      aura:id="fileId" 
      onchange="{!c.readFile}" 
      type="file" 
      name="file" 
      multiple="false"/&gt;
  
  &lt;/aura:component&gt;
  </code></pre>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>({
      readFile : function(component) {
          var file = component.find("fileId").get("v.files")[0];
          var reader  = new FileReader();
  
          reader.onload = function(e) {
              var fileContent = e.target.result;
              var base64 = 'base64,';
              var dataStart = fileContent.indexOf(base64) + base64.length;
  
              fileContent = fileContent.substring(dataStart);
              uploadFile(file, fileContent, component);
          }
          reader.readAsDataURL(file); 
      },
  
      uploadFile : function(file, fileContent, component) {
          var action = component.get("c.createFile"); 
  
          action.setParams({
              fileName: file.name,
              base64Data: encodeURIComponent(fileContent)
          });
  
          $A.enqueueAction(action);
      }
  })
  </code></pre>
  
  <p>The issue I am having is I am unable to get uploadFile() to be called from readFile(). Any suggestions would be great. Thank you.</p>