Spring MVC - AngularJS - File Upload - org.apache.commons.fileupload.FileUploadException

前端 未结 4 1165
情书的邮戳
情书的邮戳 2020-11-30 02:11

I have a Java Spring MVC Web application as server. And AngularJS based application as client.

In AngularJS, I have to upload a file and send to server.

Here

4条回答
  •  抹茶落季
    2020-11-30 02:55

    I faced the same issue and encountered the same issue even after updating the transformRequest. 'Some how, the header boundary doesn't seem to have set correctly.

    Following http://uncorkedstudios.com/blog/multipartformdata-file-upload-with-angularjs, the problem is resolved. Extract from the location....

    By setting ‘Content-Type’: undefined, the browser sets the Content-Type to multipart/form-data for us and fills in the correct boundary. Manually setting ‘Content-Type’: multipart/form-data will fail to fill in the boundary parameter of the request.

    Not sure if this helps any one but perhaps makes it easy for people looking at this post... At least, it makes it less difficult.

提交回复
热议问题