Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

538
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda