I want to Upload File To Spring boot backend , How should I send Formdata as requestparam in postrequest, i tried following code
let headers=new HttpHeaders({
'Content-Type="multipart/form-data'
})
const formData:FormData=new FormData();
formdata.apend('file',file);
return this.http.post(uploaadfile,{params:{
file:formData,
contracttemplateid:28
}},options);
@postmapping
uploadfile(@requestparam("file") MultipartFile
file,@requestparam("contracttemplateid") long id)
{
}
Uploadfile(formData: FormData, FileName: string){
return this.http.post('URL',formData,{'params': {filename : FileName}});
}
let fd = new FormData();
let FileName = "FileName";
fd.append(SeletedFile, FileName)
Uploadfile(fd,FileName);