PHP Requires Chilkat v11.0.0+
PHP
Create Password Protected Zip containing a Single File.
See more Zip Examples
Create a password-protected .zip containing a single file. (This uses the older Zip 2.0 encryption scheme, which is weaker and not as secure as AES encryption, which Chilkat Zip also supports.)Chilkat PHP Downloads
<?php
use Chilkat2\Zip;
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
$zip = new Zip();
try {
$zip->NewZip('test.zip');
} catch (\Chilkat2\Exception $e) {
echo $e->getMessage(), "\n";
exit;
}
ERROR: Method not in Chilkat2 PHP: Zip.SetPassword
$zip->ERROR();
$zip->PasswordProtect = true;
$saveExtraPath = false;
$zip->AddFile('/temp/hamlet.xml', $saveExtraPath);
try {
$zip->WriteZipAndClose();
} catch (\Chilkat2\Exception $e) {
echo $e->getMessage(), "\n";
exit;
}
echo "Zip Created!\n";