note 115803 added to ziparchive.setpassword
| From: | stanislav dot eckert at vizson dot de | Date: | Fri, 26 Sep 2014 02:43:25 +0000 |
| Subject: | note 115803 added to ziparchive.setpassword | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-200527@lists.php.net to get a copy of this message | ||
It seems that this function supports only decryption of password protected archives (see changelog:
http://pecl.php.net/package-changelog.php?package=zip).
Creation of password protected archives is not supported (they will be created simply as
non-protected archives).
Example code for extraction of files from password protected ZIP archives:
<?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 .")");
}
?>
----
Server IP: 213.172.110.14
Probable Submitter: 78.52.99.94
----
Manual Page -- http://php.net/manual/en/ziparchive.setpassword.php
Edit -- https://master.php.net/note/edit/115803
Del: integrated -- https://master.php.net/note/delete/115803/integrated
Del: useless -- https://master.php.net/note/delete/115803/useless
Del: bad code -- https://master.php.net/note/delete/115803/bad+code
Del: spam -- https://master.php.net/note/delete/115803/spam
Del: non-english -- https://master.php.net/note/delete/115803/non-english
Del: in docs -- https://master.php.net/note/delete/115803/in+docs
Del: other reasons-- https://master.php.net/note/delete/115803
Reject -- https://master.php.net/note/reject/115803
Search -- https://master.php.net/manage/user-notes.php