好的,这是我的表格:
<form action="/measure" method="post">
<input type="file" name="thisfile"/>
<input type="submit" value="Give us that file!"/>
</form>
我的服务器:
var express = require("express"),
multer = require('multer'),
app = express(),
upload = multer({ dest: "./uploads/" });
app.post("/measure", upload.single("thisfile"), function (req, res) {
console.log(req.file);
//other stuff
});
当我将表单提交到我的服务器时,req.file
未定义。
答案 0 :(得分:0)
<form action="/measure" method="post" enctype="multipart/form-data">
<input type="file" name="thisfile"/>
<input type="submit" value="Give us that file!"/>
</form>
有了它应该工作。如果这有助于你,请告诉我。 PS:这是文档:https://www.npmjs.com/package/multer