Sample code for 30+ languages & platforms
JavaScript

Unzip Text File to String

See more Zip Examples

Demonstrates how to open a .zip and extract the 1st file (assuming it's a text file) to a string variable.
Note
This example is intended for running within a Chilkat.Js embedded JavaScript engine. All Chilkat JavaScript examples require Chilkat v11.4.0 or greater.
JavaScript
var success = false;

// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

var zip = new CkZip();

success = zip.OpenZip("qa_data/zips/EC16100.zip");
if (success == false) {
    console.log(zip.LastErrorText);
    return;
}

// Get the 1st file in the .zip
var entry = new CkZipEntry();
success = zip.EntryAt(0,entry);
if (success == false) {
    console.log(zip.LastErrorText);
    return;
}

var fileContents = entry.UnzipToString(0,"utf-8");
console.log(fileContents);