multer configuration with app.use returns TypeError

后端 未结 3 1601
时光说笑
时光说笑 2020-12-30 06:10

I\'m trying to configure multer in my app.js file (using node.js/express) in order to allow users to upload images. I have the following code in app.js:

//va         


        
3条回答
  •  一向
    一向 (楼主)
    2020-12-30 06:34

    Problem is that multer({dest:'./uploads/'}) return object, not middleware function. And if we look at the code module that we will see that there are three middlware functions:

    multer({dest:'./uploads/'}).single(...)
    multer({dest:'./uploads/'}).array(...)
    multer({dest:'./uploads/'}).fields(...)
    

    Try one of them.

提交回复
热议问题