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

97
Views
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
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!