title: Getting image/video from html into java servlet as new File()
body: <p>I want to get a file (image or video) from an </p>
  
  <pre><code>&lt;input type='file' id='file_i'/&gt;
  // Not this &lt;input type='submit'/&gt;
  </code></pre>
  
  <p>Using an <code>XMLHttpRequest</code> like this</p>
  
  <pre><code>function img() {
              var fd = new FormData();
              fd.append('file', document.getElementById("file_i").files[0]);
              var req;
              if (window.ActiveXObject) {
                  req=new ActiveXObject();
              } else {
                  req=new XMLHttpRequest();
              }
              req.open("post", "Image", true);
              req.send(fd);
          }
  </code></pre>
  
  <p>for example.<br>
  Then in the servlet doing this:</p>
  
  <pre><code>new FileInputStream(new File(request.getParameter("file")))
  </code></pre>
  
  <p>How can I retrieve that file?
  Thanks in advance.</p>