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

277
Vistas
express js multer upload.single not working

Multer was uploading files okay, but then suddenly the same code does not get the file object in the request. It's like multer is being ignored completely. When checking for file in the request, req.file is undefined.

function multerStore() {
return multer.diskStorage({
    destination: function (req, file, cb) {
        console.log(req);
        execHomeDir().then(resp => {
            const nameo = resp.replace("\n", "");
            const folderPath = nameo + attachmentTemp;
            createFolder(folderPath).then(resp=>{
                cb(null, folderPath);
            }).catch(ree=>{
                cb(null, folderPath);
            });
        }).catch(ree => {
            console.error('Error Multer');
            console.error(ree);
            const nameo = ree.replace("\n", "");
            const folderPath = nameo + attachmentTemp;
            createFolder(folderPath).then(resp=>{
                cb(null, folderPath);
            }).catch(ree=>{
                cb(null, folderPath);
            });
        });
    },
    filename: function (req, file, cb) {
        console.log(req);
        console.log('Incoming file'+file.filename);
        const name = setFileName('mexuser') + file.originalname;
        cb(null, name);
    }
});}
function multerOps() {
return multer({ storage: multerStore(), limits: fileLimiter });}const attachOps = multerOps('attachment', attachmentTemp);fileRouter.post('/:type', attachOps.single('attachment'),files.upload);
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