multipart/form-data possible to send with javascript?
<p>I am sending a file over POST together with text "name" using this form:</p>

<pre><code>&lt;form enctype="multipart/form-data" action="https://site[DOT]net/upload" method="post"&gt;
  &lt;input id="name" type="text" /&gt;
  &lt;input id="data" type="file" /&gt;
  &lt;button type="submit" name="submit" /&gt;
&lt;/form&gt;
</code></pre>

<p>I would like to do the exect same using javascript. In addition I dont want to be redirected. I want to stay on the html page and just show a popup "Upload done". How can I do this in javascript (no jquery)?</p>

<p>EDIT:</p>

<p>I tried this code but the POST is not working:</p>

<pre><code>&lt;script&gt;
function uploader {
  var formData = new FormData();
  formData.append("name", "Smith");
  formData.append("data", fileInputElement.files[0]);
  var request = new XMLHttpRequest();

  request.open("POST", "https://site[DOT]net/upload");
  request.send(formData);
}
&lt;/script&gt;

&lt;form&gt;
    &lt;input id="name" type="text" /&gt;
    &lt;input id="data" type="file" /&gt;
    &lt;button type="submit" name="submit" /&gt;
    &lt;button onclick="uploader()"&gt;Click&lt;/button&gt;
&lt;/form&gt;
</code></pre>