How could I upload files in ExpressJS 4.x

express, node.js

Solution

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.

Problem

I know there are something like `multiparty`, and `busboy` and formidable. I want to know is there any chance to upload files without them.

Original source

Related problems