我正在尝试使用以下路由将文件上传并保存到根文件夹中名为“ uploads”的文件夹中,但是它无法保存任何内容,而且我什至都没有收到任何错误消息。我找不到问题。
router.post("/tracker/:id/po", function(req,res){
Tracker.findById(req.params.id, function(err, foundTracker){
if(err){
console.log(err);
}else{
var user = req.user.id;
var id = req.params.id;
var fileName = 'C' + id + '.pdf';
var storage = multer.diskStorage({
destination: function (req,file, callback){
callback(null, './uploads/'+ user + '/trackers');
},
filename: function (req, file, callback){
callback(null, fileName);
}
});
var upload = multer ({storage : storage}).single("file");
upload(req, res, function(err){
console.log(user);
res.redirect("/tracker/"+req.params.id+"/info");
});
}
});
});