1.node-formidable
Components to help with file uploads
2.app.js
var formidable = require (' formidable '), var http = require (' http '), var sys = require (' sys '), Http.createserver (function ( request, Response) {if (request.url = = '/upload ' && request.method.toLowerCase () = = ' Post ') {cons Ole.log (' upload requet ') uploadrequest (request,response); Return } enterrequest (request,response)}). listen, function enterrequest (request, response) {response.writehead (200 , {' content-type ': ' text/html '}); Response.End (' <form action = "/upload" enctype= "multipart/form-data" method= "post" > ' + ' <input ty PE = "text" name = "title"/> <br> ' + ' <input type = "file" name= "upload" multiple= "multiple"/> < ;br/> ' + ' <input type= "submit" value= "Upload now"/> ' + ' </form> ');} /** * Handling Upload logic * @param request * @param response */function uploadrequest (request,response) {var form = new Formidab Le. Incomingform (); Form.parse (request, function (err, fields, files) {response.writehead ($, {' content-type ': ' Text/plain '}); Response.Write (' reviced Upload file '); Response.End (sys.inspect ({fields:fields, files:files})); });}
Node. js Image upload