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

后端 未结 2 718
长发绾君心
长发绾君心 2020-12-31 11:32

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

相关标签:
2条回答
  • 2020-12-31 11:57

    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();
    }
    
    0 讨论(0)
  • 2020-12-31 12:16

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

    echo shell_exec('unzip -P password file.zip');
    
    0 讨论(0)
提交回复
热议问题