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

154
Views
req.files sigue regresando indefinido

req.files sigue regresando indefinido. Probé connect-multiparty, body-parser y express-fileupload. ¿Cómo hago que funcione usando express-fileupload y no multer?

aquí está mi interfaz:

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

Lo he comprobado usando la pestaña de red de elementos de inspección, está enviando la imagen bien.

aquí está mi back-end:

 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.") });

¿Cómo puedo solucionar esto?

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

0

También debe especificar el enctype adecuado como atributo de formulario, así:

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