所以我要开始我的身体解析器和还我使用“multer”Bodyparser为多的NodeJS
我multer选项:在服务器
var multer = require('multer');
var storage = multer.diskStorage({
destination: function (req, file, cb) {
cb(null, '/root/Unicon-Oauth/Resources/profile_images/')
},
filename: function (req, file, cb) {
cb(null, file.fieldname + '-' + Date.now())
}
});
var pfImage = multer({storage:storage});
身体解析器。 JS
app.use(bodyParser.urlencoded({extended:true,limit: '20MB',parameterLimit:10000}));
app.use(bodyParser.json());
我有这样的
路线3210router.post('/edit',[auth.isAuthenticated,pfImage.single('pImage')],actions.edit);
功能就是这样
function edit(req,res)
{
console.log(req.body);
}
控制台日志输出:
块引用
{“------ WebKitFormBoundaryGS8GEzQls8xRP6nt \ r \ nContent处置:形状数据; name“:”\“_ id \”\ r \ n \ r \ n58a4735cfa328b7e9eaf6a3a \ r \ n ------ WebKitFormBoundaryGS8GEzQls8xRP6nt \ r \ nContent-Disposition:form-data; name = \“city \”\ r \ n \ r \ nKayseri \ r \ n ------ WebKitFormBoundaryGS8GEzQls8xRP6nt \ r \ nContent-Disposition:form-data; name = \“name \”\ r \ n \ r \ nali \ r \ n ------ WebKitFormBoundaryGS8GEzQls8xRP6nt \ r \ nContent-Disposition:form-data;名字= \ “\” \ r \ n \ r \ n \ r \ n ------ WebKitFormBoundaryGS8GEzQls8xRP6nt - \ r \ n“}
如何可以解析这是req.body
?
你想通过url传递图像数据吗? – carebdayrvis
nope通过邮递员我加了sc reenshots –