Files are only sent with postman but not with file input

Viewed 46

When I send a file through the form, I get req.file is undefined. But through Postman, I get the file. Why?

<form action="/up" method="POST" enctype="multipart/form-data" class="row">

            <section class="col-md-8 border mt-2">

                <label for="name" class="form-label">Name</label>
                <input type="text" class="form-control" name="name" id="name">
              
                <label for="csv" class="form-label">CSV File</label>
                <input type="file" id="csv" name="csv" accept=".csv">
                                          
                <label for="rounds" class="form-label">Rounds</label>
                <input type="number" class="form-control" id="rounds" name="rounds" min="0">          

                <button type="submit" class="btn btn-primary mb-3">Guardar</button>
                <button  class="btn btn-warning mb-3">Cancelar</button>
      

Route

router.post('/up', upCSV.single('csv'), newCamp);

Multer Middleware

const storage = multer.memoryStorage();       
const upload = multer({ storage: storage});

Files are only sent with Postman but not with file input.

0 Answers
Related