express + multer返回自定义消息

时间:2020-01-15 13:59:03

标签: express return multer

我使用var upload = multer({dest: './upload'}).array('photo', 3).

如果上传5个文件,则返回错误消息"files exceeding the limit 2"
如果上传7个文件,则返回错误消息"files exceeding the limit 4"

我的代码

    var express = require('express');
    var multer = require('multer');
    var app = express();
    var upload = multer({dest: './upload'}).array('photo', 3)
    function uploadMiddleware(request, response, next) {
        upload(request, response, (err)=>{
            if (err) {
                console.log(err)
            } else {
                next();
            }
        })
    }
    app.post('/upload',uploadMiddleware, function (request, response) {
    })
    app.listen(8888)

我不知道该怎么办

非常感谢!

0 个答案:

没有答案