How to upload multiple image with other information using form data in Angular

image upload multiple form-data Angular

How to upload multiple images with other information using form data in Angular
My request type

let body = {
    files: //here files array,
    message: //here json data 
}

Service method

return this.http.post(this.baseApisupUrl + 'addUpdate',body,{}).pipe();

Please provide me solutions
thanks 

Solutions (1)
  • Ashish Pokle 3 months, 6 days, 47 minutes ago
    Look on the below Code, this will help you for upload multiple image in a ajax request

    this.documentList = [...]  //File Array
    this.baseApiUrl = '...'  // Your api path
    formData = FormData();
    // other information 
    this.formData.append("message", JSON.stringify(body));
    // add multiple files in a form data
    this.documentList.forEach(item => {
        this.formData.append("file", item)
      }) 
    }
    //  server api calling
     this.http.post(this.baseApiUrl, body,{
        reportProgress: true
    }).pipe();

Your Answer To Login
Add Answer