Spring Boot + Angular file upload unable to upload same file twice

后端 未结 2 1952
隐瞒了意图╮
隐瞒了意图╮ 2021-01-07 12:55

Error under Network in chrome

{ timeStamp: ......, status: 400
  error: \'Bad Request\',
  message: \'Required request part \'file\' is not present\'
  path:         


        
相关标签:
2条回答
  • 2021-01-07 13:16

    Param annotation in your controller looks for a field called file.

    Change selectFile to file will solve the problem.

    formData.append("file", this.data);
    

    Parameter name matters in this, it has to be same in both Java & Angular

    0 讨论(0)
  • 2021-01-07 13:33

    This:

    formData.append("selectFile", this.data);
    

    to that:

    formData.append("file", this.data);
    

    Cause

    public ResponseEntity<String> handleFileUpload(@RequestParam("file") 
    
    0 讨论(0)
提交回复
热议问题