CreateNew(); // start a new empty archive for adding files // or $zip->Open('an_existing_archive.zip'); // open an existing archive for reading and/or modifying // -------------------------------------------------- // Reading information and data in the opened archive // -------------------------------------------------- // check if a file is existing in the archive, the name must precise subfolders if any $ok = $zip->FileExists('subfolder/help.html'); // count the files stored in the archive $file_nbr = count($zip->CdFileLst); // retrieve the content of an compressed file in the archive $text1 = $zip->FileRead('readme.txt'); // retrieve the content of an compressed file in a subfolder of the archive $text2 = $zip->FileRead('subfolder/readme.txt'); if ($ok) $zip->FileExists('subfolder/help.html'); // ----------------------------- // Modifying data in the archive // ----------------------------- // add a file in the archive $zip->FileAdd('newfile.txt', $data, TBSZIP_STRING); // add the file by giving the content $zip->FileAdd('newpic1.png', './images/localpic1.png', TBSZIP_FILE); // add the file by copying a local file $zip->FileAdd('newpic2.png', './images/localpic2.png', TBSZIP_FILE, false); // add the uncompressed file by copying a local file // delete an existing file in the archive $zip->FileReplace('newfile.txt', $data, TBSZIP_STRING); // replace the file by giving the content $zip->FileReplace('newpic1.png', './images/localpic1.png', TBSZIP_FILE); // replace the file by copying a local file $zip->FileReplace('newpic2.png', './images/localpic2.png', TBSZIP_FILE, false); // replace the uncompressed file by copying a local file $zip->FileReplace('newpic3.png', false); // delete the file in the archive // cancel the last modification on the file (add/replace/delete) $zip->FileCancelModif('newpic2.png'); // ---------------------- // Applying modifications // ---------------------- $zip->Flush(TBSZIP_FILE, './save/new_archive.zip'); // apply modifications as a new local file // apply modifications as an HTTP downloaded file $zip->Flush(TBSZIP_DOWNLOAD, 'download.zip'); $zip->Flush(TBSZIP_DOWNLOAD, 'download.zip', 'application/zip'); // with a specific Content-Type // apply modifications as a downloaded file with your customized HTTP headers header("Content-type: application/force-download"); header("Content-Disposition: attachment; filename=download.zip"); header("Expires: Fri, 01 Jan 2010 05:00:00 GMT"); $zip->Flush(TBSZIP_DOWNLOAD+TBSZIP_NOHEADER); // ----------------- // Close the archive // ----------------- $zip->Close(); // stop to work with the opened archive. Modifications are not applied to the opened archive, use Flush() to commit
声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章
R.E.P.O.能量晶体解释及其做什么(黄色晶体)
3 周前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最佳图形设置
3 周前By尊渡假赌尊渡假赌尊渡假赌
刺客信条阴影:贝壳谜语解决方案
2 周前ByDDD
R.E.P.O.如果您听不到任何人,如何修复音频
3 周前By尊渡假赌尊渡假赌尊渡假赌
WWE 2K25:如何解锁Myrise中的所有内容
3 周前By尊渡假赌尊渡假赌尊渡假赌

热工具

Atom编辑器mac版下载
最流行的的开源编辑器

适用于 Eclipse 的 SAP NetWeaver 服务器适配器
将Eclipse与SAP NetWeaver应用服务器集成。

禅工作室 13.0.1
功能强大的PHP集成开发环境

VSCode Windows 64位 下载
微软推出的免费、功能强大的一款IDE编辑器

ZendStudio 13.5.1 Mac
功能强大的PHP集成开发环境