我正在使用multer将一些文件上传到我的存储设备,但是操作失败。这是我的代码:
const multer = require('multer');
var storage = multer.diskStorage({
destination: function (req, file, callback) {
callback(null, './public/uploads');
},
filename: function (req, file, callback) {
callback(null, file.fieldname + '-' + Date.now());
}
});
var upload = multer({ storage : storage}).single('avatar');
当我使用此行时:
app.post("/upload", upload, function(req, res) {
console.log(req.files);
}
我得到
的日志响应{ avatar:
{ name: 'Mobile Application.doc',
data: <Buffer d0 cf 1.....>,
encoding: '7bit',
tempFilePath: undefined,
truncated: false,
mimetype: 'application/msword',
md5: [Function: md5],
mv: [Function: mv] } }
application/msword
我正在尝试查找文件的路径,但我不能。请帮助