ThinkPHP6上传zip文件并解压缩
2023-03-29 23:03:03
546
{{single.collect_count}}

ThinkPHP6上传zip文件并解压缩

function uploadFile($key){$file = request()->file('file_name');try{// 验证文件格式validate(['file'=>['fileExt' => 'zip','fileMime' => 'application/zip']])->check(['file' => $file]);// 移动到框架应用根目录/public/uploads/zip 目录下$info = \think\facade\Filesystem::disk('public')->putFile( 'zip', $file);// 拼接上传后的文件绝对路径$uploadPath = str_replace('\\','/','./uploads/'.$info);// 定义解压路径$unzipPath = './uploads/unzip/'.date('Ymd').'/'.basename($uploadPath,".zip");// 实例化对象$zip = new \ZipArchive() ;//打开zip文档,如果打开失败返回提示信息if ($zip->open($uploadPath,\ZipArchive::CREATE) !== TRUE) {
回帖
全部回帖({{commentCount}})
{{item.user.nickname}} {{item.user.group_title}} {{item.friend_time}}
{{item.content}}
{{item.comment_content_show ? '取消' : '回复'}} 删除
回帖
{{reply.user.nickname}} {{reply.user.group_title}} {{reply.friend_time}}
{{reply.content}}
{{reply.comment_content_show ? '取消' : '回复'}} 删除
回帖
收起
没有更多啦~
{{commentLoading ? '加载中...' : '查看更多评论'}}