title: How to work with the url of a fileReader object?
body: <p><br>
  Hello! I'am trying to make it work a function called <code>loadDocument</code>, who need a url of the loaded files from the user local computer to work. I'm writing an API to load document from local user computer, and show it on a web reader.</p>
  
  <p>This is my upload button :
    <code>&lt;input type="file" id="input" onchange="module.onLoadSelection();" alt="Browse" name="upload"/&gt;</code></p>
  
  <p>This is my function without fileReader :</p>
  
  <pre class="lang-js prettyprint-override"><code>var onLoadSelection = function () {
      var select = document.getElementById('input');
      if (select &amp;&amp; select.value) {
          var id= '';
          var url = select.files.item(0).name;
          module.loadDocument(url,id);
      }
  };
  </code></pre>
  
  <p>This is my function with fileReader :</p>
  
  <pre class="lang-js prettyprint-override"><code>var loadTest = function (input) {
      var file = document.querySelector('input[type=file]').files[0];
      console.log("file loaded! -&gt;", file); // i can read the obj of my file
      var reader = new FileReader();
  
      var id = ''; // don't need rightnow
      var url = reader.readAsDataURL(file);
      console.log("url :", url); // show me undefined....
      module.loadDocument(url,id);
  }
  </code></pre>
  
  <p>What i am trying is to get the url of the loaded file from user computer to get my function loadDocument working. She need a url parameter to work.</p>
  
  <p><code>loadDocument</code> is an API function, i assume i can't get the filepath of my user due to security reason.</p>
  
  <p>What do i need to change/update on my <code>loadDocument();</code> function to work?</p>
  
  <p>Edit : In fact, nothing to change. The correct way to read my file was :
  <code>&lt;input type="file" id="input" onchange="module.onLoadSelection(this.files);" alt="Browse" name="upload"/&gt;</code></p>
  
  <pre class="lang-js prettyprint-override"><code>var onLoadSelection = function (files) {
      if (files &amp;&amp; files.length == 1) {
         var id = '';
         var url = URL.createObjectURL(files[0]);
         module.loadDocument(url,id);
      }
  };
  </code></pre>