How to extract zip file in client system using javascript

I have a zip file on the server. I upload a zip file to the client system. Now I want to extract the file using javascript. someone please help me. thanks in advance.

+3
source share
4 answers

You can unzip the zip files in memory in the browser using Javascript.

This answer shows how to do this.

The js code in the browser is as follows:

var doneReading = function(zip){
    DoSomethingWithEntries(zip);
};

var zipFile = new ZipFile(url, doneReading); 

Inside the method DoSomethingWithEntriesthat you provide, you can play with an object representing the extracted zip file.

function DoSomethingWithEntries(zip){ 
  // for each entry in the zip...
  for (var i=0; i<zip.entries.length; i++) {
    var entry = zip.entries[i];
    var entryInfo = "<h4><a>" + entry.name + "</a></h4>\n<div>";  
    // put that into a div, if you like.
    // etc...
  }
}

As shown above, you can emit lists of records with their name, size, date, etc.

extract() zip. ( ) , . ( , ), javascript . .

, , , - javascript - , Google Gears, Silverlight Flash.

+7

. ( javascript). -.

- -, zip bajillion Mb , .

+2

javascript .

ActiveX, java- ..

+1

Internet Explorer Windows, ActiveX COM-, , , WScript.Shell :

var shell = new ActiveXObject('WScript.Shell');
shell.run( '"unzip.exe command line stuff or whatever you want to do here..."' ); 

, , , , , , .

-1

Source: https://habr.com/ru/post/1781641/


All Articles