所以,当我上传文件时,我没有显示任何错误,它只是没有上传文件,我得到消息'0文件上传成功,我确实在数据库中获取每个上传项目的记录
所以,这是输入表格
<form action='./make' method="post">
<input type="file" name="vid"> <br>
<input type="text" name="name"> <br>
<input type="hidden" name="_csrf" value="<%= _csrf %>">
<input type="hidden" name="ownerID" value="<%= req.session.User.id %>">
<input type="submit" value="add video">
</form>
这就是'make'动作:
make: function (req, res, next) {
Video.create(req.params.all(), function videoCreated (err,video) {
console.log("create video");
// if(err) return next(err);
req.file('vid').upload({
dirname: './assets/images'
}, function (err, uploadedFiles) {
if (err) return res.negotiate(err);
return res.json({
message: uploadedFiles.length + ' file(s) uploaded successfully!'
});
});
if(err){
console.log(err);
req.session.flash = {
err: err
}
return res.redirect('/user/new');
}
});
}