express框架,使用multer中間件,用form表單post請求接口,返回500;二話不說,先上代碼。。。這個是路由設(shè)置的://routes.js
saveUrl=multer({dest:path.join(__host,'public','demo')})
app.post(
'/addDemo',
saveUrl.single('files1'),
function(req,res){
handle=require('./post/addDemo.js');
handle(req,res);
}
);這是handle里面處理的//addDemo.js
//什么都沒有處理,直接end,對吧。。。
var?querystring=require('querystring');
var?db=require(__host+'/db/mongod.js');
module.exports=function(req,res){
console.log(req.body);
res.end();
}這個是html代碼:<form?method="post"?action="http://localhost:3000/addDemo"?enctype="multipart/form-data">
????<input?type="text"?name="name"/>
????<input?type="file"?name="files1"/>
????<input?type="submit"?value="提交"/>
</form>這個是返回值:這個500是怎么來的。。。為什么會出現(xiàn)500?另外。。。。這個提問不能使用makedown語法么?。。。
添加回答
舉報
0/150
提交
取消