用 koa-multer 这模块,上传是可以成功了,但是成功之后的回调都没有执行~~~求大佬搭救一把
这是代码
const Koa = require('koa');
const route = require('koa-route');
const multer = require('koa-multer');
const serve = require('koa-static');
const app = new Koa();
app.use(serve(__dirname + '/koa-upload/'));
const upload = multer({ dest: 'uploads/' });
app.use(route.post('/profile', upload.single('avatar'), async function(ctx) {
console.log(123)
}));
app.listen(3000);
console.log('listening on port 3000');
koa-upload/index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<form id='editfile' method='post' action='/profile' enctype='multipart/form-data'>
<input name="text" type="text"/>
选择图片:<input name="avatar" id='upfile' type='file'/>
<input type='submit' value='提交'/>
</form>
</body>
</html>
图片是可以上传到uploads文件夹里面,可是console.log(123)这句话就没没有执行,后面就没有办法拿到文件信息了呀