Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

537
Views
How to upload multiple array of images/files using multer node js sequelize

Request Parameters:

{ 

    "project_name":"",
    
    "city":"",
    
    "street":"",
    
    "property_type":[
    
    {
    
    "id":"1",
    
    "property_type":"type",
    
    "floor_plan_img":["1654513514684-download (2).jpg","1654513514684-download.jpg"]
    
    },
    
    {
    
    "id":"2",
    
    "property_type":"type",
    
    "floor_plan_img":["1654513514684-download-1.jpg","1654513514684-new.jpg"]
    
    }]
}

CODE

var propertyTypeInfo=[];
if(req.body.property_type_data && typeof(req.body.property_type_data) == 'string'){
    propertyTypeInfo=JSON.parse(req.body.property_type_data)
    console.log(typeof(propertyTypeInfo))
}else{
   propertyTypeInfo=req.body.property_type_data
}


var floorPlanImgs=[];
if(req.files.floor_plan_img)
{
    floorPlanImgs = req.files.floor_plan_img? req.files.floor_plan_img:'';
}


           if(propertyTypeInfo.length >0){
                for(let i=0;i<propertyTypeInfo.length;i++){     
                    let data=[];
                    if(req.files.floor_plan_img[i].filename){
                        console.log('IMDATA');
                        var floorPlanImg = req.files.floor_plan_img.map(function(file) {
                            return file.filename;
                        });
                        
                        if(floorPlanImg[i].length > 0){
                            console.log(floorPlanImg.length,'[i]floorPlanImg[i]');
                            for(let j=0;j<floorPlanImg[i].length;j++){
                                floorPlanImg = req.files.floor_plan_img.map(function(file) {
                                    return file.filename; // or file.originalname
                                });
                                data.push(floorPlanImg[j]);
                            }
                        }
                           
                        console.log(data[i],'floorPlanImgdata');
                    }
                    PropertyType.create({
                        property_type:propertyTypeInfo[i].property_type,
                        floor_plans_img:data[i],
                    })
                }
            }

Above are the request parameters and sample code of multer file upload. Here property type is an array of object ,inside property_type floor_plan_img is another array of files/images.

Trying to upload multiple array of images/files for repective property_type.But after iteration stroing storing single image/file for floor_plan_img field.

Can you please help me to resolve the issue. And share the form data postman request for multiple array of images/files.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!