Please try my fragment code:
For some information, the structure of my application is as shown below:
my path --> C:\xampp\htdocs\service service | -- tmp\ | -- app.js | -- index.html
Client side:
<html> <body> <h3>ZIP Upload:</h3> <form action="/upload_zip" method="POST" enctype="multipart/form-data"> Select zip to upload: <input type="file" name="zipFile" id="zipFile"> <input type="submit" value="Upload ZIP" name="submit"> </form> </body> </html>
Server side:
Remember to use enctype="multipart/form-data" when you publish it using the mail manager or something like that ...
var express = require("express"); var fs = require("fs"); var AdmZip = require('adm-zip'); var app = express(); var multer = require("multer"); var multer_dest = multer({dest: "./tmp"}).single('zipFile'); app.get("/",function(req,res){ console.log("Show index.html"); res.sendFile(__dirname+"/"+"index.html"); }); app.post("/upload_zip",multer_dest,function(req,res){ console.log(req.file); var zip = new AdmZip(req.file.path); zip.extractAllTo("./tmp"); result = { file:req.file, message:"File has been extracted" }; fs.unlink(req.file.path, function (e) { if (e) throw e; console.log('successfully deleted '+req.file.path); }); res.end(JSON.stringify(result)); }); var server = app.listen(8081,function(){ var host = server.address().address; var port = server.address().port; console.log("Example App Listening at http://%s:%s",host,port); })
Output:

source share