您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

php中使用zip

2024/4/3 12:30:55发布16次查看
简介:这是php中使用zip的详细页面,介绍了和php,php, zip php中使用zip有关的知识、技巧、经验,和一些php源码等。
class='pingjiaf' frameborder='0' src='http://biancheng.dnbcw.info/pingjia.php?id=350525' scrolling='no'>   在php中,可以使用php自己的zip功能去为某些文件打包和解压,这点来说比其他语言
都很方便,方法小结如下:
1 打开php.ini中的扩展extension,启用(php 5.2以后有这个功能)
  extension= php_zip.dll
2 压缩文件
   // creating object of the ziparchive $zip = new ziparchive(); $ow = 1; $file= c:\\master.zip; if($zip->open($file,$ow?ziparchive::overwrite:ziparchive::create)===true) { //增加一个文件 $zip->addfile(c:\\master.txt); //a1.txt会被保存加压到a2.txt $zip->addfile(c:\\a1.txt, c:\\a2.txt); $zip->addfile(c:\\a3.txt); //关闭 $zip->close(); } ?>
3 解压
  $zip = new ziparchive(); //打开master.zip if ($zip->open(master.zip) === true) { //解压的路径 $zip->extractto(/path/to/folder/); $zip->close(); } // 只解压一个文件 // open master.zip for extracting single files if ($zip->open(master.zip) === true) { // will extract only fonts.css from master.zip to given path. $zip->extractto(/path/to/folder/,fonts.css); $zip->close(); } //解压多个文件 if ($zip->open(master.zip) === true) { $files = array(fonts.css,master.css); $zip->extractto(/path/to/folder/,$files); $zip->close(); }
爱j2ee关注java迈克尔杰克逊视频站json在线工具
http://biancheng.dnbcw.info/php/350525.html pageno:3
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product