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

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