Dating multer

This is the traditional method of transfering files over HTTP.I was nervous about doing this because it would significantly increase the amount of data the server would consume.

Multer is a popular Node JS middleware package for handling file uploads.

Lets have a look at our complete Server file, I’ll explain parts of it later.

We are going to use basic FORM submit along with Ajax submit j Query plugin to make it asynchronous. var express = require("express"); var body Parser = require("body-parser"); var multer = require('multer'); var app = express(); app.use(body Parser.json()); var storage = Storage(); var upload = multer().array('user Photo',2); app.get('/',function(req,res));'/api/photo',function(req,res)); app.listen(3000,function()); Here rather than .single() we are using .array(selector,file Limit) of Multer.

Multer will accept array of files limiting to max 2 file at each time. On Form submit, we will stop the page refresh by returning FALSE and call the API using ajax Submit().

The renaming function can be customized according to your needs.