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

149
Views
req.files keeps returning undefined

req.files keeps returning undefined. I've tried connect-multiparty, body-parser, and express-fileupload. How do I make it work using express-fileupload and not multer?

here's my frontend:

<form action="/api/upload" method="post">
    <label for="imgHere">file:</label>
    <input type="file" id="imgHere" name="imgHere"><br><br>
    <input type="submit">
</form>

I've checked using inspect element network tab, its sending the image just fine.

here's my backend:

const express = require("express");
const app = express();
const fileUpload = require("express-fileupload")

app.use(fileUpload())

app.post('/api/upload', function(req, res) {
  console.log(req.files) // logs undefined
  res.send("uploaded.")
});

app.listen(80, function()
{
    console.log("Server loaded.")
});

How do I fix this?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You need to specify proper enctype as form attribute as well, like this:

<form action="/api/upload" method="post" enctype="multipart/form-data">
    <label for="imgHere">file:</label>
    <input type="file" id="imgHere" name="imgHere"><br><br>
    <input type="submit">
</form>
about 4 years ago · Juan Pablo Isaza Report
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!