richardgirges / express-fileupload

Simple express file upload middleware that wraps around busboy
MIT License
1.52k stars 261 forks source link

req.files is undefined #306

Closed okpyard closed 2 years ago

okpyard commented 2 years ago

I use this code `const express = require('express') const app = express() const port = 3000 const fileupload = require("express-fileupload"); app.use(fileupload());

app.post("/", (req, res) => { if (!req.files) { res.send("File was not found"); return; }

const file = req.files.file; res.send(${file.name} File Uploaded); });

app.listen(port, () => { console.log(Example app listening at http://localhost:${port}) })`

but req.files is undefined

Screenshot 2022-03-13 at 18 20 58
malletgaetan commented 2 years ago

Hi,

your code is working just fine, ensure that you're correctly using postman (it seems correct from the image), if you're still facing this issue, please share your express and express-fileupload version

nischay2x commented 2 years ago
"express": "^4.17.3",
"express-fileupload": "^1.3.1",

Mine is this, and I am getting the same error. It was working fine 1 week ago.

sergiorivera50 commented 2 years ago

@nischay2x @Okpyard Remove the file from the body request in Postman and add it again. It is a known bug that hasn't been solved yet.

salloom-domani commented 2 years ago

I'm having the same issue and it's not working for postman. I tried removing and adding the file field but still not working..