<code>$zip = new ZipArchive(); $code = $zip->open('myzip.zip', ZipArchive::CREATE | ZipArchive::OVERWRITE); if ($code === true) echo 'zip opened<br>'; else echo $code.'<br>'; $zip->addFile('somefile'); $code = $zip->setPassword('secret'); if ($code === true) echo 'password set<br>'; else var_dump($code); $code = $zip->close(); on the filesystem, the myzip.zip is created with somefile inside and $code is true but the zip file is not password protected ... </code>
<code>$zip = new ZipArchive(); $code = $zip->open('myzip.zip', ZipArchive::CREATE | ZipArchive::OVERWRITE); if ($code === true) echo 'zip opened<br>'; else echo $code.'<br>'; $zip->addFile('somefile'); $code = $zip->setPassword('secret'); if ($code === true) echo 'password set<br>'; else var_dump($code); $code = $zip->close(); on the filesystem, the myzip.zip is created with somefile inside and $code is true but the zip file is not password protected ... </code>
setPassword
비밀번호가 없는 ZIP 파일에 비밀번호를 설정하는 것이 아니라 복호화를 위해 비밀번호를 설정하는 것입니다.
<code class="php">$zip = new ZipArchive(); $code = $zip->open('myzip.zip'); $zip->setPassword('123456'); $zip->extractTo('/path');</code>