1 Star 1 Fork 1

tekintian / php-tzip

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

PHP zip打包压缩工具

简单,快速,高效的在线ZIP文件打包压缩下载工具. 支持php5, php7, php8

使用方法:

Composer 方式

  1. Composer安装类库

    # 加载php-tzip类库
    composer require  tekintian/php-tzip
    
  2. 使用示例

    可查看 tests/demo.php文件中的相关演示

    <?php
    
    require_once __DIR__ . '/../vendor/autoload.php';
    
    // 实例化对象
    $zip = new tekintian\TZip();
    
    // 指定你要压缩的文件路径,可以是相对路径或者绝对路径
    $path = "../";
    // 输出的文件路径
    $outfile = __DIR__ . "/test.zip";
    
    // 读取目录
    $zip->readDir($path, false);
    // 在压缩包内添加一个目录 demo1 这里的目录是你最终的压缩包中的目录,非你本地现有的目录!
    $zip->addDir('demo1');
    $data = file_get_contents('./demo.txt');
    // 将demo.txt数据存放到压缩包的demo1/demo.txt 注意这个操作说指定的目录demo1必须先通过 addDir创建
    $zip->addData('demo1/demo.txt', $data);
    
    // 将文件通过浏览器下载
    // $zip->download($outfile);
    // 打包目录中的文件为test.zip
    $zip->archive($outfile);
    # 清理数据
    $zip->clearData();
    
    

专业企业信息化软件研发, 个性化软件定制开发,手机APP开发服务商. 服务热线:13888011868 QQ:932256355

MIT License Copyright (c) 2023 tekintian Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

简单,快速,高效的在线ZIP文件打包压缩下载工具. 支持php5, php7, php8 展开 收起
PHP
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
PHP
1
https://gitee.com/tekintian/php-tzip.git
git@gitee.com:tekintian/php-tzip.git
tekintian
php-tzip
php-tzip
master

搜索帮助