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

180
Views
Express Fileupload only working on one router

So i'm in this situation where the route /update-propic in user-router.js has correct use of express-fileupload middleware but /img/upload in image-host-router.js has req.files to null (obv even when files are sent)

I've also discovered that the first router "used"(aka imported) in server.js gets access to express-fileupload but the other ones do not

this is my folder tree:

server/
├─ src/
│  ├─ routers/
│  │  ├─ image-host-routes.js
│  │  ├─ user-routes.js
├─ server.js

server.js

...other requires
const fileUpload = require("express-fileupload");

// Init express
const app = express();

// Middlewares
app.use(fileUpload());
...other middlewares


// Login Routes
app.use(require("./src/routers/user-routes"));

// Blog Post Routes
app.use(require("./src/routers/blog-post-routes"));

// Comment Routes
app.use(require("./src/routers/comment-routes"));

// Image hosting routes
app.use(require("./src/routers/image-host-routes"));

const PORT = 5000;
app.listen(PORT, () => console.log(`Server is running on localhost:${PORT}`));

user-routes.js

...other requires
const express = require("express");
const router = express.Router();

//NOTE: no `use` middlewares present
router.post("/update-propic", checkAuthenticated, (req, res) => {
    try {
        console.log(req.files); // Console logs correctly the `files` object
    } catch (err) {
        //
    }
});

img-host-routes.js

const express = require("express");

const router = express.Router();

router.post("/img/upload", [checkAdmin], (req, res) => {
    try {
        console.log(req.files); // Logs `null`
    } catch (err) {
        //
    }
});
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!