«

express处理form-data文件数据,使用multer

emer 发布于 2018-7-5 22:21   3318 次阅读     


var express = require('express');
var router = express.Router();
var cookieParser = require('cookie-parser');
var md5=require("md5");
var sql1=require("../libs/sql");
var session = require('express-session');
var multer=require("multer");
/* GET home page. */
var upload = multer({dest: './upload'});

router.post('/',upload.fields([
    {name: 'file'}
]),function(req, res, next) {
     res.json(req.files);
       console.log(req.files);

});

module.exports = router;

如果是posg withx-www-form-urlencoded那么用req.body