如何解压带密码的压缩包
作者:互联网
环境要求,php>=7.3 并且需要安装 7-zip 自行点击链接下载即可
Windows: 7-zip >= 7.30 (7-Zip)
找个文件夹 composer下来 以下是目录结构
composer require gemorroj/archive7z (如何有错执行下 composer self-update)
require ('vendor/autoload.php'); use Archive7z\Archive7z; function test7Z($path,$dest_path,$password=''){ $obj = new Archive7z($path); // 密码校验一定要放前面 因为调用isValid什么的会校验密码 $obj->setPassword($password); if (!$obj->isValid()) { return false; } try { $obj->setOutputDirectory($dest_path)->extract(); } catch (\Archive7z\Exception $e) { return false; } return true; } $path = 'C:\Users\zhengjb\Desktop\test\1\testrat.rar'; $dest_path = 'C:\Users\zhengjb\Desktop\test\1'; test7Z($path,$dest_path);
标签:解压,obj,dest,return,密码,composer,Archive7z,path,压缩包 来源: https://www.cnblogs.com/jiangzuo/p/16141372.html