Node.js 显示未定义的正文解析的req.files

Node.js 显示未定义的正文解析的req.files,node.js,Node.js,您应该添加一个中间件来处理文件,因为bodyParser不处理文件。引用bodyParser的自述: 这不处理多部分实体,因为它们复杂且通常较大。对于多部分实体,您可能对以下模块感兴趣: 接线员和接线员 多方和连接多方 可怕的 穆特 app.use(bodyParser.urlencoded({ extended: false })); app.use(bodyParser.json()); app.post('/upload', function (req, res) { conso

您应该添加一个中间件来处理文件,因为bodyParser不处理文件。引用bodyParser的自述:

这不处理多部分实体,因为它们复杂且通常较大。对于多部分实体,您可能对以下模块感兴趣:

接线员和接线员 多方和连接多方 可怕的 穆特
app.use(bodyParser.urlencoded({ extended: false })); 
app.use(bodyParser.json()); 

app.post('/upload', function (req, res) {
  console.log('hari :'+req.body.purpose);
  timeNow = Date.now();
  var jobID = timeNow + '_' + Math.floor((Math.random() * 10000000000000) + 1);
  var rethinkObj = config.rethinkdb;
  var data = {
    "id": jobID,
    "finished_at": timeNow,
    "last_update": timeNow,
    "log": "add job",
    "process_instructions": "",
    "start_at": timeNow,
    "status": "in-progress"
  }
  rethink.insertDataIntoTable(rethinkObj, data).then(function(insertedData){
    console.log(insertedData);
    console.log('new row inserted into RethinkDB', data.id);

    uploadFile(req, res, jobID);

  })
});