As a newcomer to Angular 4 and Web API, I am currently working on uploading multiple images from an Angular 4 application to the Web API.
While I have successfully received the images in the API and can see the count of uploaded images during debugging, I am facing an issue when trying to save the images in a folder. Only one image is being stored and in the database, all image paths are showing the same path.
During debugging, I noticed that all the images in the foreach loop are displaying the same image name.
In my service.ts file for Angular 4:
ImageInsert(mObject, mImage) {
const formData: FormData = new FormData();
formData.append('mFormData', JSON.stringify(mObject));
for (const file of mImage) {
formData.append('ImageFile', file, file.name);
}
return this.http.post(this.BASE_URL + `/api/ImageInsert`, formData)
}
If anyone has any insights or solutions to help me resolve this issue, it would be greatly appreciated.