File uploading with Express 4.0: req.files undefined

后端 未结 9 1873
感动是毒
感动是毒 2020-11-22 10:10

I\'m attempting to get a simple file upload mechanism working with Express 4.0 but I keep getting undefined for req.files in the app.post

9条回答
  •  爱一瞬间的悲伤
    2020-11-22 11:08

    The body-parser module only handles JSON and urlencoded form submissions, not multipart (which would be the case if you're uploading files).

    For multipart, you'd need to use something like connect-busboy or multer or connect-multiparty (multiparty/formidable is what was originally used in the express bodyParser middleware). Also FWIW, I'm working on an even higher level layer on top of busboy called reformed. It comes with an Express middleware and can also be used separately.

提交回复
热议问题