一区二区三区在线-一区二区三区亚洲视频-一区二区三区亚洲-一区二区三区午夜-一区二区三区四区在线视频-一区二区三区四区在线免费观看

服務器之家:專注于服務器技術及軟件下載分享
分類導航

PHP教程|ASP.NET教程|Java教程|ASP教程|編程技術|正則表達式|C/C++|IOS|C#|Swift|Android|VB|R語言|JavaScript|易語言|vb.net|

服務器之家 - 編程語言 - PHP教程 - PHP Zip壓縮 在線對文件進行壓縮的函數

PHP Zip壓縮 在線對文件進行壓縮的函數

2019-10-30 16:40php教程網 PHP教程

PHP在線對文件進行Zip 壓縮函數代碼,用于使用PHP在線創建ZIP壓縮文件。

代碼如下:


/* creates a compressed zip file */ 
function create_zip($files = array(),$destination = '',$overwrite = false) { 
//if the zip file already exists and overwrite is false, return false 
if(file_exists($destination) && !$overwrite) { return false; } 
//vars 
$valid_files = array(); 
//if files were passed in... 
if(is_array($files)) { 
//cycle through each file 
foreach($files as $file) { 
//make sure the file exists 
if(file_exists($file)) { 
$valid_files[] = $file; 



//if we have good files... 
if(count($valid_files)) { 
//create the archive 
$zip = new ZipArchive(); 
if($zip->open($destination,$overwrite ? ZIPARCHIVE::OVERWRITE : ZIPARCHIVE::CREATE) !== true) { 
return false; 

//add the files 
foreach($valid_files as $file) { 
$zip->addFile($file,$file); 

//debug 
//echo 'The zip archive contains ',$zip->numFiles,' files with a status of ',$zip->status; 

//close the zip -- done! 
$zip->close(); 

//check to make sure the file exists 
return file_exists($destination); 

else 

return false; 


/***** Example Usage ***/ 
$files=array('file1.jpg', 'file2.jpg', 'file3.gif'); 
create_zip($files, 'myzipfile.zip', true); 

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: japonensis中国东北老人 | 2020年精品国产午夜福利在线 | 草草视频人人爽 | 亚洲第一页综合 | 精品国产人成亚洲区 | 久久综合视频网站 | 色多多影院 | 秋霞午夜伦午夜高清福利片 | 无限在线观看免费入口 | bb18lv黑料正能量 | 99久女女精品视频在线观看 | japan孕妇孕交freehd | 人人澡 人人澡碰人人看软件 | 日本xxx在线观看免费播放 | 亚洲色欧美图 | 亚洲国产精品线在线观看 | 免费视频亚洲 | 忘忧草在线社区WWW日本-韩国 | 成人香蕉xxxxxxx | 能播放的欧美同性videos | 国产精品毛片无码 | 午夜网 | 五月最新女厕所高跟嘘嘘 | 四虎e234hcom| avav男人天堂 | 色天天久久| 久久这里有精品 | 欧美人xxxxxbbbb| 亚洲熟区 | 久久99精品久久久久久园产越南 | 午夜理论电影在线观看亚洲 | 动态图啪啪120秒免费看 | 国产成人精选免费视频 | 奇米影视小说 | 国产美女做爰免费视频软件 | 91精品啪在线观看国产老湿机 | 国产综合成人久久大片91 | 欧美性理论片在线观看片免费 | 国产成人精品视频午夜 | 成人涩涩屋福利视频 | 黄漫在线播放 |