开发者

How can I extract a password protected .zip file from within my PHP application?

开发者 https://www.devze.com 2023-02-25 13:40 出处:网络
How can I extract a password protected .zip file 开发者_如何学Cfrom within my PHP application?Since PHP 5.6.0 you can use the class ZipArchive. Encrypted files can be decrypted by setting a password w

How can I extract a password protected .zip file 开发者_如何学Cfrom within my PHP application?


Since PHP 5.6.0 you can use the class ZipArchive. Encrypted files can be decrypted by setting a password with the setPassword() method.

$zip = new ZipArchive();
if ($zip->open('file.zip') === true) {
    $zip->setPassword('MyPassword');
    $zip->extractTo('/my/destination/dir/');
    $zip->close();
}


You can use this (assuming your server has the "right" os :-))

echo shell_exec('unzip -P password file.zip');
0

精彩评论

暂无评论...
验证码 换一张
取 消