title: Not getting the file data while FormData is used
body: <p>Here I want to hit the api of the golang to upload a file on the local system using javascript. To get the key, value pair for file I read the FormData method in the javascript and I used it in my code but it will not taking the key, value while I'm assigning the data. I have posted my code.</p>
  
  <pre><code>function uploadFile(){
            var url = "http://localhost:8081/shapi/v1/upload";
            var archivoSeleccionado = document.getElementById("myfile");
            var file = archivoSeleccionado.files[0];
            var f = new FormData();
            console.log(file)
            f.append("file", file);
            console.log("f", f)
            var xmlHTTP= new XMLHttpRequest();
            xmlHTTP.open("POST", url, true);
            xmlHTTP.send(f);
  }
  </code></pre>
  
  <p>In console of  <code>console.log(file)</code> it will print </p>
  
  <pre><code>File { name: "541660.jpg", lastModified: 1537849576000, webkitRelativePath: "", size: 243477, type: "image/jpeg" }
  </code></pre>
  
  <p>In console of  <code>console.log("f", f)</code> it will print:-</p>
  
  <pre><code>FormData {  }
  </code></pre>
  
  <p>Can anyone tell me the problem in my code?</p>
  
  <p>Runnable Snippet</p>
  
  <p><div class="snippet" data-lang="js" data-hide="true" data-console="true" data-babel="false">
  <div class="snippet-code snippet-currently-hidden">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function uploadFile() {
    var archivoSeleccionado = document.getElementById("myfile");
    var file = archivoSeleccionado.files[0];
    var f = new FormData();
    console.log(file)
    f.append("file", file);
    console.log("f", f)
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;input id="myfile" type="file" /&gt;
  &lt;button onclick="uploadFile()"&gt;Upload&lt;/button&gt;</code></pre>
  </div>
  </div>
  </p>