i am trying to upload image in angular.
I do this step:
In service i use this settings:
postFormDataToServerMultiPart(action: string, formData) {
var headerss = new HttpHeaders({
"Content-Type": "multipart/form-data"
});
return this.http
.post(HttpService.apiUrl + action, formData, { headers: headerss })
.pipe(map((response: any) => response));
}
headers contain : "Content-Type": "multipart/form-data"
In component.ts :
var formData = new FormData();
formData.append("file", this.imageForm.get("profile").value);
if (this.Image) {
this.httpService
.postFormDataToServerMultiPart(
"api/upload/driver_image?id=" + this.employeeId,
formData
)
.subscribe((resp) => {
console.log("edit", resp);
if (resp.status == "SUCCESS") {
var dialogRef = this.dialog.open(DisplayPopupComponent, {
data: {
title: "Driver Updated Successfully!",
},
............
I receive this error :
error: "Internal Server Error"
message: "Current request is not a multipart request"
path: "/api/upload/driver_image"
status: 500
timestamp: "2021-07-09T13:45:23.443+0000"
what i do wrong?
What in miss?