I need assistance or recommendations
---------------#################---------------
Is there a way to upload an image in a form using formcontrolName? Any suggestions would be appreciated.
------------###########################---------------------
I have been attempting to upload an image file along with other information such as firstname
, lastname
and file
and it is functioning correctly:
/* File Upload request to Upload file */
this.currentFileUpload = this.selectedFiles.item(0);
let formdata: FormData = new FormData();
formdata.append('firstName', "Harkesh");
formdata.append('lastName', "kumar");
formdata.append('file', this.currentFileUpload);
However, my issue lies in sending a FORM
file along with a string and an Object
, as FormData
does not accept the latter:
let formdata: FormData = new FormData();
formdata.append('functionId', this.functionId);
formdata.append('processId', this.processId);
formdata.append('file', this.currentFileUpload);
formdata.append('formDetails', userobjArr);
A second option I am exploring:
let formdata: FormData = new FormData();
formdata.append('file', this.currentFileUpload);
userDetails.name = "";
userobjWrapper["functionId"] = this.functionId;
userobjWrapper["processId"] = this.processId;
userobjWrapper["taskId"] = this.taskId;
userobjWrapper["file"] = this.currentFileUpload;
userobjWrapper["formDetails"] = userobjArr;
userobjArr
is an array of Objects
that I assign to formDetails
, which ends up with a value of null
.
I am uncertain about how to fetch an image in one rest Service API call. For the REST API, I am utilizing a Spring Boot Rest Controller.
Any ideas on how to proceed would be greatly appreciated.