vue路由代码片段

时间:2021-02-28 11:10:04
// var upload = multer({ dest: 'public/uploads/' , fileFilter: fileFilter});
// 文件上传
router.post('/upload.api',upload.single('upfile'),function(req,res,next){
  console.log(req.file);
  res.set('Content-Type', 'text/plain');
  res.send({
    "state": "SUCCESS",
    "url": req.file.path.slice(req.file.path.indexOf('/') + 1),
    "title": req.file.fieldname,
    "original": req.file.originalname
  })
});