所以我要開始我的身體解析器和還我使用「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 –