title: Upload file on the server through REST API
body: <p>I'm trying to upload file on server through REST API. My api requests FormData model, but Im getting <code>400 bad request</code> error.</p>
  
  <p><strong>payload from my request in devtools</strong></p>
  
  <p>------WebKitFormBoundaryvPiRGxMC3Ru3AoFA
  Content-Disposition: form-data; name="file"; filename="test.jpg"
  Content-Type: image/jpeg</p>
  
  <p>------WebKitFormBoundaryvPiRGxMC3Ru3AoFA--</p>
  
  <p><strong>payload from my docs</strong></p>
  
  <p>file: (binary)</p>
  
  <p>Just look some code below.</p>
  
  <p>upload.component.html</p>
  
  <p><code>&lt;input type="file" accept="image/*" (change)="onFileChange($event)"&gt;</code></p>
  
  <p>upload.component.ts</p>
  
  <pre><code>uploadForm = this._fb.group({
      profile: ['']
  });
  formData: FormData = new FormData();
  ...
  onFileChange(event): void {
      if (event.target.files &amp;&amp; event.target.files.length) {
          const file = event.target.files[0];
          this.uploadForm.get('profile').setValue(file);
      };
  }
  ...
  upload() {
      this.formData.append('file', this.uploadForm.get('profile').value);
      // API REQUEST
  }
  </code></pre>
  
  <p>`</p>
  
  <p>Is that the good way to change my input value to <code>FormData</code>?</p>