无法读取未定义 (req.file) 的 属性 'fileSize' (multer)
Cannot read property 'fileSize' of undefined (req.file) (multer)
代码:
var upload = multer({dest:"./uploads"});
app.post("/", upload.single("file"), function (req, res, next) {
res.send(req.file.fileSize+"bytes");
});
EJS 文件:
<h1>Get the File Size of your Upload !</h1>
<form enctype="multipart/form-data" method="post" action="/" name="file">
<input type="file" class="form-control">
<button type = "submit" class = "btn btn-default">Submit</button>
</form>
问题:
我做错了什么?
将名字='file'添加到输入
<h1>Get the File Size of your Upload !</h1>
<form enctype="multipart/form-data" method="post" action="/">
<input type="file" class="form-control" name="file">
<button type = "submit" class = "btn btn-default">Submit</button>
</form>
代码:
var upload = multer({dest:"./uploads"});
app.post("/", upload.single("file"), function (req, res, next) {
res.send(req.file.fileSize+"bytes");
});
EJS 文件:
<h1>Get the File Size of your Upload !</h1>
<form enctype="multipart/form-data" method="post" action="/" name="file">
<input type="file" class="form-control">
<button type = "submit" class = "btn btn-default">Submit</button>
</form>
问题:
我做错了什么?
将名字='file'添加到输入
<h1>Get the File Size of your Upload !</h1>
<form enctype="multipart/form-data" method="post" action="/">
<input type="file" class="form-control" name="file">
<button type = "submit" class = "btn btn-default">Submit</button>
</form>