我正在尝试使用节点js上传PDF文件,但我能够这样做。 如果有任何插件或multer可以使用相同的请帮助。 在这里我上传个人资料图片我想上传PDF文件,它可以存储超过30个文件。
//var multer = require('multer')
//var upload = multer({ dest: 'public/uploads/' });
router.post('/speaker', upload.single('profile_pic'), function (req, res) {
var speakerForm = JSON.parse(req.body.speaker);
var speaker = new Speaker();
speaker.name = speakerForm.name;
speaker.job_title = speakerForm.job_title;
speaker.email = speakerForm.email;
speaker.company = speakerForm.company;
speaker.description = speakerForm.description;
speaker.uid = speakerForm.uid;
if(req.file){
var profile_pic = req.file;
profile_pic.destination = "uploads/";
profile_pic.path = "uploads/"+profile_pic.filename;
speaker.profile_pic = profile_pic;
}
speaker.save(function(err,speakerobj){
if(err){
return res.send(500, err);
}
return res.json(speakerobj);
});
});