How could I upload files in ExpressJS 4.x

Without them, parsing multipart forms can be hard to do right and efficiently. Unless you really want to go through that work of parsing multipart yourself (urlencoded forms are much easier), you really should stick to using one of connect-multiparty, multer, connect-busboy, reformed, etc.


If you want to upload files you need to be able to parse multipart content. You can either use to parse it or implement your own. Here's a list the modules that can help you:

Direct parsing (in descending popularity based on Github stars as of Nov 2016):

  • formidable
  • busboy
  • multiparty

Middleware:

  • multer - based on busboy, much more popular than options below
  • busboy middleware - last commit April 2014
  • multiparty middleware - suggests not to use on Github page

Both:

  • parted - last commit Jan 2015

If you want to write your own parser, you can have a look how above modules does it. Check these links also:

  • Here's how it looks like
  • multipart protocol spec and html spec
  • Blog post about implementing formidable
  • bop: Boyer Moore Parser, good node module to find the multipart boundaries position
  • Another blog post about implementing multi-part parser

Happy coding.