多映像上传到Spring Boot

时间:2018-12-05 10:50:54

标签: angular spring-boot

我正在尝试从Angle 4前端上载多个文件到Spring Boot服务器。

  selectedFile : File []  = [];
  filesToUpload: File[] = [];
  selectedFileNames: string[] = [];

  readURL(fileInput) {
    // this.detectFiles(fileInput);
    this.filesToUpload = <Array<File>>fileInput.target.files;
    for (let i = 0; i < this.filesToUpload.length; i++)
    {
        this.selectedFile.push(fileInput.target.files[i]);
    }
    console.log(this.selectedFile)
}

onUpload2(){
    const fd = new FormData();
    for (var i = 0; i < this.filesToUpload.length; i++){
      fd.append('fileseee',this.selectedFile[i],this.selectedFile[i].name);
    }

    this.questionService.uploadImages(fd).
    subscribe( 
      (data: any) => {
           }
         )
   }



uploadImages(fda){
  console.log(fda);
  return this.http.post(this.apiUrl+"/imageUpload112",fda)
  .map((res : Response) => res);
}

后端Spring引导代码与邮递员一起正常工作。 错误显示为“请求处理失败;嵌套异常为

[org.springframework.web.multipart.MultipartException:当前请求不是多部分请求],其根本原因是

0 个答案:

没有答案