title: How to upload files(multipart) using angularjs2
body: <p>Do angular2 supports multipart form submit, any example available?</p>
  
  <p>Any link to docs specific to this is much appreciated </p>
  
  <p>See post from angular github <a href="https://github.com/angular/angular/issues/6030" rel="noreferrer">https://github.com/angular/angular/issues/6030</a></p>
  
  <h1>**** Updated later with  Working Demo using XMLHttpRequest ****</h1>
  
  <p>Any example showcasing sending  <code>FormData</code> as part of <code>http</code>,  </p>
  
  <p>Below is a draft code which works fine for me but like to know if same supported in <code>http</code></p>
  
  <h1>HTML</h1>
  
  <pre><code>  &lt;input id="single_f_fileup" [(ngModel)]="model.image" type="file" (change)="selectFile($event)" name="single_fileup" /&gt;
  </code></pre>
  
  <h1>ANGULAR2</h1>
  
  <pre><code>selectFile($event): void {
   var files = $event.target.files || $event.srcElement.files;
          var file = files[0];
          let formData = new FormData();
          formData.append("single_fileup", file);
          formData.append('key1', 'value1');
          formData.append('key2', 'value2');
         var req = new XMLHttpRequest();
         req.open("POST", "/api/fileupload");
         req.send(formData);
  }
  </code></pre>
  
  <h1>NODEJS 6.2</h1>
  
  <pre><code>var multer  = require('multer');
  var storage = multer.memoryStorage();
  var upload = multer({ storage: storage });
    router.post('/api/fileupload', upload.single('single_fileup'), function(req, res, next){
          console.log(req.body,req.file);
  });
  </code></pre>
  
  <h1>How to make below code work?</h1>
  
  <pre><code> this.http.post('/api/fileupload', formData)
              .map(this.extractData)
              .catch(this.handleError);
  </code></pre>