开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜