title: How to send multiple files from Angular as FormData to Spring Boot as MultipartFile[]?
body: <p>My code below is for a single file upload, but I am trying to send multiple files from Angular to Spring Boot all at once. Sending multiple formdata to an ArrayList in Spring Boot results in <code>null</code>, and I can't <code>@RequestParam</code> a single formdata in Spring Boot, since the amount of files sent from Angular is dynamic (defined by the user). Could anyone please help?</p>
  <p>Spring Boot controller:</p>
  <pre><code>@PostMapping(&quot;/jobAdApplication&quot;)
  public void jobAdApplication (@RequestParam(&quot;files&quot;) MultipartFile[] files, 
     @RequestParam(&quot;candidateName&quot;) String candidateName) {
         (...)
  }
  </code></pre>
  <p>Angular component:</p>
  <pre><code>selectedFiles!: FileList;
  file!: file;
  
  (...)
  
  if (this.selectedFiles) {
     let file: File | null = null;
     const formData: FormData = new FormData();
  
     for (let i = 0; i &lt; this.selectedFiles.length; i++) {
        file = this.selectedFiles.item(i);
        if (file) {
           formData.append(`file${i}`, file);
        }
     }
  
     formData.append('candidateName', this.applyFormGroup.get('name')?.value);
  
     this.fileService.uploadFile(formData).subscribe({
        next: response =&gt; {
           alert('Files sent successfully')
           this.applyFormGroup.reset();
        },
        error: err =&gt; {
           alert(`Error: ${err.message}`);
        }
     });
  
     this.selectedFiles = undefined;
  }
  
  </code></pre>
  <p>Angular service:</p>
  <pre><code>uploadFile(jobAdApplication: FormData): Observable&lt;any&gt; {
     return this._http.post&lt;any&gt;(`${this.jobCandidateUrl}/jobAdApplication`, jobAdApplication);
  }
  </code></pre>