如何获得和本地存储从前端上传的文件

我有一个接受批处理名称(下拉),参数(textarea),电子邮件ID(testing)和batch file.txtinput文件(文件)的HTML代码。 当我点击前端表单中的“提交”时,我会在日志中看到下面的内容:

GET /batch?batches=Batch1 - - ms - - 

我不知道如何知道和提取和存储在服务器端通过NodeJS脚本的文件名? 还有最新的方式来捕获textarea由用户提交?

 <form action="batch"> <label for="batch">Select Batch&nbsp;&nbsp;</label> <select name="batches" id="batch"> <select name="batches" id="batch"> <option value="" disabled="disabled" selected="selected">Please select a batch</option> <option value="1">Batch1</option> <option value="2">Batch2</option> <option value="3">Batch3</option> <option value="4">Batch4</option> <option value="5">Batch5</option> </select> </p> <br/> <p> <label for="binpfile">Batch Input File</label> <input type="file" id="binpfile" accept=".txt"> </p> <br/> <p> <label for="emailid">E-Mail ID:</label> <input type="text" id="emailid"><br> </p> <br/> <p class="formfield"> <label for="bparam">Batch Parameters:</label> <textarea rows="4" cols="50" id="bparam" form="usrform">Enter batch param here...</textarea> <input type="submit" value="Submit"> </form> 

下面是我的NodeJS代码: 我在日志中看到“User entered Batch1 undefined undefined undefined”

 exports.processbatch = function(req, resp) { var bname = req.query['batches']; var fname = req.query['binpfile']; var emailid = req.query['emailid']; var bparam = req.query['bparam']; console.log ('User entered ' + bname + ' ' + fname + ' ' + emailid + ' ' + bparam); }; 

为什么不检查'req.query'对象?

的console.log(REQ);

你可以使用Muller来处理file upload。 结合body-parser。

在完成任务后,您将在req.file中获取文件。