I want to send a file and a hidden input text in a form.
<form method="POST" action="/api/import_xlsx_data" enctype="multipart/form-data">
<input type="file" name="xlsx_file_to_import" accept=".xlsx" required>
<input id="url" type="HIDDEN" name="url" value="url-value">
<input type="submit" value="Envoyer">
In my controller request.body is equal to {}.
When I remove enctype="multipart/form-data" it works for my text but not for my file.
To upload my file :
uploadFile.upload({saveAs : fileName, dirname : directoryName},function onUploadComplete(err, files) { ...............});
My controller :
importXLS: function (req, res) {
var uploadFile = req.file('xlsx_file_to_import');
//console.log(req.params()); -> send error params is not a function
console.log(req.body); // send me {}
console.log(req.param('url')); //send me undefined
...... }
More code on pastbin :
My view : view
My controller : controller