精华内容
下载资源
问答
  • <?php /** * Created by. * User: Jim * Date: 2020/7/30 * Time: 11:14 */ namespace app\index\controller; use app\index\services\SystemLogService; use think\Controller;... protected $mid
    <?php
    /**
     * Created by.
     * User: Jim
     * Date: 2020/7/30
     * Time: 11:14
     */
    
    namespace app\index\controller;
    
    
    use app\index\services\SystemLogService;
    use think\Controller;
    use think\facade\Request;
    
    class Index extends Controller
    {
    
        protected $middleware = [];
    
        public function index()
        {
            //这里需要注意该目录是否存在,并且有创建的权限
            $zipname = 'test.zip';
            //这是要打包的文件地址数组
            $files = [
                'img/1.png',
                'img/2.png',
                'img/3.png',
                'img/4.png',
            ];
            $zip = new \ZipArchive();
            $res = $zip->open($zipname, \ZipArchive::CREATE);
            if ($res === TRUE) {
                foreach ($files as $file) {
                    //这里直接用原文件的名字进行打包,也可以直接命名,需要注意如果文件名字一样会导致后面文件覆盖前面的文件,所以建议重新命名
    //                $fileContent = file_get_contents($file);
    //                $file = iconv('utf-8', 'GBK', basename($file));
    //                $zip->addFromString($file, $fileContent);
                    $zip->addFromString($file, $file);
                }
            }
    
            header('Content-Type: application/zip;charset=utf8');
            header('Content-disposition: attachment; filename=文件' . date('Y-m-d') . '.zip');
            header('Content-Length: ' . filesize($zipname));
            readfile($zipname);
            die;
        }
    }
    
    展开全文
  • Archive.zip

    2021-04-08 08:19:34
    Archive.zip
  • ZipArchive is a simple utility class for zipping and unzipping files on iOS, macOS and tvOS. Unzip zip files; Unzip password protected zip files; Unzip AES encrypted zip files; Create zip files; ...
  • ZipArchive

    2015-09-09 13:43:15
    iOS 解压缩文件类库,ZipArchive
  • ZipArchive 解压zip

    2019-07-31 03:46:52
    NULL 博文链接:https://andydufresneone.iteye.com/blog/1050203
  • I can also see in Notepad++ that the ZipArchive zip is different from the WinRAR zip, and the file size is different. I can successfully call winrar as a system command in ...
  • ziparchive

    2015-02-11 14:35:19
    ZipArchive is an Objective-C class to compress or uncompress zip files, which is base on open source code "MiniZip". It can be used for iPhone application development, and cocoa on Mac OSX as well.
  • Archive.Zip Errors

    2020-12-27 05:42:13
    <div><p>The current Zip class fails to create a simple archive , bug can be reproduce with the following winxed code : <pre><code> var archive = new ["Archive","Zip"]; archive.add...
  • zipArchive

    热门讨论 2012-04-25 16:28:57
    ZipArchive is an Objective-C class to compress or uncompress zip files, which is base on open source code "MiniZip". It can be used for iPhone application development, and cocoa on Mac OSX as well.
  • PHP安装zip扩展,ZipArchive解压zip文件 打印phpinfo();查看是否已经安装zip扩展及是否开启,未安装或开启按照如下方法操作 http://pecl.php.net/package/zip下载相应php版本的Windows版本zip包。 下载解压后...

    PHP安装zip扩展,ZipArchive解压zip文件

    打印phpinfo();查看是否已经安装zip扩展及是否开启,未安装或开启按照如下方法操作

    http://pecl.php.net/package/zip 下载相应php版本的Windows版本zip包。

    下载解压后,将php_zip.dll和php_zip.pdb这两个文件,复制到PHP安装目录下的ext文件夹下。

    然后修改php.ini配置文件,载入zip扩展 extension=php_zip.dll,保存后重启服务。

    ZipArchive解压zip文件

    开启后zip类报错,注意实例化时需在前面加上‘\’ ,即

    $zip = new \ZipArchive();
    dd($zip);

    打印结果如下即可应用该类进行操作

     

    展开全文
  • Archive-Zip-SimpleZip:Perl5界面,可读写Zip文件
  • iOS用ZipArchive解压zip

    千次阅读 2014-01-06 13:19:06
    iOS用ZipArchive解压zip包 引入框架 libz.dylib 引入头文件 "ZipArchive.h" 1. 解压: 1 - (void) extractingArchive { 2 NSString *path = [NSHomeDirectory() ...

    iOS用ZipArchive解压zip包


    引入框架 libz.dylib
    引入头文件 "ZipArchive.h"

    1. 解压:

    复制代码
     1 - (void) extractingArchive {
     2     NSString *path = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
     3    
     4     NSString *filePath = [path stringByAppendingPathComponent:@"luzhan.zip"];
     5     NSString *unZipPath = [path stringByAppendingPathComponent:@"luzhan"];
     6    
     7     ZipArchive *zip = [[ZipArchive alloc] init];
     8    
     9     BOOL result;
    10    
    11     if ([zip UnzipOpenFile:filePath]) {
    12         result = [zip UnzipFileTo:unZipPath overWrite:YES];
    13         if (!result) {
    14             NSLog(@"解压失败");
    15         }
    16         else
    17         {
    18             readBtn.enabled = YES;
    19             NSLog(@"解压成功");
    20         }
    21         [zip UnzipCloseFile];
    22     }
    23 }
    展开全文
  • ZipArchive

    千次阅读 2011-03-10 12:25:00
    重启apache PHP Version 5.2.5<br />出现这个错误说明是程序在调用'ZipArchive' 这个类的时候没有成功,原因是由于在安装php的时候没有增加php zip的支持(非zlib)。 在Windows下的解决办法是 : 1...

     
    确认php安装文件夹下的ext文件夹中具有php_zip.dll文件
    修改php.ini
    打开
    extension=php_zip.dll
    重启apache
    PHP Version 5.2.5

    出现这个错误说明是程序在调用'ZipArchive' 这个类的时候没有成功,原因是由于在安装php的时候没有增加php zip的支持(非zlib)。

    在Windows下的解决办法是 :

    1、在php.ini文件中,将extension=php_zip.dll前面的分号“;”去除,然后同样在php.ini文件中,将 zlib.output_compression = Off 改为 zlib.output_compression = On ;

    2、重启Apache服务器。

    在Unix/Linux下的解决办法 :

    1、在Linux下没有php_zip.dll这个文件(有也不会起作用的),所以需要重新编译一下php的zip模块。具体安装方法如下:

    cd /usr/src
    wget http://pecl.php.net/get/zip
    tar -zxvf zip
    cd zip-1.x.x
    phpize
    ./configure
    make
    sudo make instal

    其中, 在最后使用make install命令的时候,可能需要用到root的权限,所以建议使用sudo来运行。安装完之后,屏幕上会提示zip.so的位置。然后将其记录下来,如:/usr/local/lib/php/extensions/zip.so。

    2、使用root权限修改php.ini(通常可能会在/usr/local/lib/文件夹下,不过视当初安装php而定,可以通过phpinfo()来查看):

    增加extension = /usr/local/lib/php/extensions/zip.so,然后同样在php.ini文件中,将 zlib.output_compression = Off 改为 zlib.output_compression = On ;

    3、最后别忘了重启一下Apache:apachectl restart;

    这个针对php的zip模块就安装完成了,能够在php中使用ZipArchive类了。

    初步看了一下ZipArchive文档,简单地封装了一下压缩和解压功能.代码如下:

    /*
    * CompressZipFile: 压缩文件
    * lpszFile: 需要压缩的文件
    * lpszZipFile: 要压缩到的目标文件
    * bAppend: 标志是否添加到现有压缩文件
    * 返回压缩成功与否
    */
    BOOL  CompressZipFile( LPCTSTR lpszFile, LPCTSTR lpszZipFile, BOOL  bAppend  =  FALSE )
    {
         // 如果是追加到现有压缩文件,但现有压缩文件不存在的话  直接返回失败
         if ( bAppend  &&  (  ! ::PathFileExists( lpszZipFile ) ) )
             return  FALSE;

         int  nMode  =  bAppend  ?  CZipArchive::zipOpen : CZipArchive::zipCreate;
        CZipArchive zipArchive;
         if (  ! zipArchive.Open( lpszZipFile, nMode ) )
             return  FALSE;

         // 获取路径中的文件名部分
        TCHAR szFile[MAX_PATH];
        lstrcpy( szFile, lpszFile );
        ::PathStripPath( szFile );

         bool   bRet  =  zipArchive.AddNewFile( lpszFile, szFile );

        zipArchive.Close();

         return  bRet;

    }

    /*
    *  ExtractZipFile : 解压指定文件
    * lpszZipFile: 要解压的文件
    * lpszDestPath: 指定解压到的目录
    * 返回压缩成功与否
    */
    BOOL  ExtractZipFile( LPCTSTR lpszZipFile, LPCTSTR lpszDestPath )
    {
         if (  ! ::PathFileExists( lpszZipFile ))
             return  FALSE;

        CZipArchive zipArchive;
         if (  ! zipArchive.Open( lpszZipFile, CZipArchive::zipOpenReadOnly ) )
             return  FALSE;

         for  (  int  nIndex  =   0 ;  nIndex  <  zipArchive.GetCount (); nIndex ++  )
        {
             if (  ! zipArchive.ExtractFile( (WORD)nIndex, lpszDestPath ) )
                 break ;
        }
        zipArchive.Close();

         return  TRUE;
    }
    压缩文件夹可以参考如下的Demo:

        CZipArchive zipArchive;
         if (  ! zipArchive.Open( _T( " D://aaa.zip " ) , CZipArchive::zipCreate ) )
             return ;
         // 压缩目录下的所有文件,第三个参数指示是否递归压缩子目录,第五个参数指示是否连文件夹目录一起压缩
        zipArchive.AddNewFiles( _T( " D://aaa// " ), _T( " *.* " ),  true ,  - 1 ,  false  );   
        zipArchive.Close();

     

     

     

     


    $newFile="ziptemp/{$id}.zip";
    @copy("mailcons.zip",$newFile);
    $zip = new ZipArchive;
    if($zip->open($newFile) === TRUE) {
    $zip->addFile($imgUrl, '图'.$i.".".$ext);
    $zip->addFromString('内容.txt',"标题:{$titel}/r/n内容:/r/n".$body);
    $zip->close();

        * zip_close — Close a ZIP file archive
        * zip_entry_close — Close a directory entry
        * zip_entry_compressedsize — Retrieve the compressed size of a directory entry
        * zip_entry_compressionmethod — Retrieve the compression method of a directory entry
        * zip_entry_filesize — Retrieve the actual file size of a directory entry
        * zip_entry_name — Retrieve the name of a directory entry
        * zip_entry_open — Open a directory entry for reading
        * zip_entry_read — Read from an open directory entry
        * zip_open — Open a ZIP file archive
        * zip_read — Read next entry in a ZIP file archive
        * ZipArchive::addEmptyDir — Add a new directory
        * ZipArchive::addFile — Adds a file to a ZIP archive from the given path
        * ZipArchive::addFromString — Add a file to a ZIP archive using its contents
        * ZipArchive::close — Close the active archive (opened or newly created)
        * ZipArchive::deleteIndex — delete an entry in the archive using its index
        * ZipArchive::deleteName — delete an entry in the archive using its name
        * ZipArchive::extractTo — Extract the archive contents
        * ZipArchive::getArchiveComment — Returns the Zip archive comment
        * ZipArchive::getCommentIndex — Returns the comment of an entry using the entry index
        * ZipArchive::getCommentName — Returns the comment of an entry using the entry name
        * ZipArchive::getFromIndex — Returns the entry contents using its index.
        * ZipArchive::getFromName — Returns the entry contents using its name.
        * ZipArchive::getNameIndex — Returns the name of an entry using its index
        * ZipArchive::getStream — Get a file handler to the entry defined by its name (read only).
        * ZipArchive::locateName — Returns the index of the entry in the archive
        * ZipArchive::open — Open a ZIP file archive
        * ZipArchive::renameIndex — Renames an entry defined by its index
        * ZipArchive::renameName — Renames an entry defined by its name
        * ZipArchive::setArchiveComment — Set the comment of a ZIP archive
        * ZipArchive::setCommentIndex — Set the comment of an entry defined by its index
        * ZipArchive::setCommentName — Set the comment of an entry defined by its name
        * ZipArchive::statIndex — Get the details of an entry defined by its index.
        * ZipArchive::statName — Get the details of an entry defined by its name.
        * ZipArchive::unchangeAll — Undo all changes done in the archive.
        * ZipArchive::unchangeArchive — Revert all global changes done in the archive.
        * ZipArchive::unchangeIndex — Revert all changes done to an entry at the given index.
        * ZipArchive::unchangeName — Revert all changes done to an entry with the given name.


    本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/taipingliebeiluo/archive/2010/08/27/5844137.aspx

    展开全文
  • ios应用源码之新版ziparchive,新增创建以及解压加密zip 文件_ziparchive

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 15,159
精华内容 6,063
关键字:

archivezip