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

100
Vistas
req.body returns an empty object

I'm trying to upload a file and I noticed that when I put the enctype="multipart/form-data" in the form it returns an empty object, but when I remove it, it works fine.

In my app.js I used:

const app = express();
app.use(express.urlencoded({extended: true}));
app.use(express.json());

and in the controller:

const multer = require('multer');
const Grupos = mongoose.model('Grupos');
const shortid = require('shortid');
const configMulter = {
    sotrage: fileStorage = multer.diskStorage({
        destination: (req, file, next) => {
            next(null, __dirname+'\\..\\public\\uploads\\grupos');
        },
        filename: (req, file, next) => {
            const extension = file.mimetype.split('/')[1];
            next(null, `${shortid.generate()}.${extension}`);
        }
    })
}

const upload = multer(configMulter).single('imagen');

exports.subirImagen = (req, res, next) => {

    upload(res, req, function(error) {
        
        if(errores){
            console.log(error);
        }
        else{
            next();
        }

    })

    }

Could it be an ejs problem? I made very similar projects with pug and handlebars and they worked fine.

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