按着github上的例子还是出错。
<form id="addimgForm" method="post" enctype="multipart/form-data" action="/profile">
<input type='file' id='uploadedimg' name="file" accept='.jpg,.jpeg,.gif,.png,.bmp' ></input>
<button type="submit">上传</button>
</form>
var upload = multer({
storage: multer.diskStorage({
destination: function (req, file, cb) {
cb(null, './uploads/')
},
filename: function (req, file, cb) {
cb(null, file.originalname)
}
})
});
//var upload = multer({ dest: 'uploads/' })
app.post('/profile',upload.single('avatar'),function (req, res, next) {
// req.file is the `avatar` file
// req.body will hold the text fields, if there were any
console.log(req.file);
})
回复 (3)
参与回复
登录后即可参与回复。登录