I just want to set password in already existing zip archive,
I use method $zip->setPassword("MySecretPassword")
,
The function returns true, but password is absent.
After code running I can extract files without puting password.
Here is my code like this:
<?php
$zip = new ZipArchive();
$zip_status = $zip->open("test.zip");
if ($zip_status === true)
{
if ($zip->setPassword("MySecretPassword"))
{
if (!$zip->extractTo(__DIR__))
echo "Extraction failed (wrong password?)";
}
$zip->close();
}
else
{
die("Failed opening archive: ". @$zip->getStatusString() . " (code: ". $zip_status .")");
}
?>
Can any one help me.