php實現(xiàn)zip文件解壓操作
更新時間:2015年11月03日 14:48:37 投稿:lijiao
這篇文章主要介紹了php實現(xiàn)zip文件解壓操作的函數(shù)代碼,每一條函數(shù)代碼都有對應(yīng)的文字注釋,需要的朋友可以參考下
PHP解壓zip文件函數(shù),源碼簡短,需要使用 ZZIPlib library 擴展,使用前請確認(rèn)該擴展已經(jīng)開啟。
<? /********************** *@file - path to zip file 需要解壓的文件的路徑 *@destination - destination directory for unzipped files 解壓之后存放的路徑 *@需要使用 ZZIPlib library ,請確認(rèn)該擴展已經(jīng)開啟 */ function unzip_file($file, $destination){ // 實例化對象 $zip = new ZipArchive() ; //打開zip文檔,如果打開失敗返回提示信息 if ($zip->open($file) !== TRUE) { die ("Could not open archive"); } //將壓縮文件解壓到指定的目錄下 $zip->extractTo($destination); //關(guān)閉zip文檔 $zip->close(); echo 'Archive extracted to directory'; } //測試執(zhí)行 //unzip_file("func.zip","jieya"); ?>
這就是php解壓zip文件的函數(shù)代碼,希望對大家的學(xué)習(xí)有所幫助。
相關(guān)文章
thinkphp中U方法按路由規(guī)則生成url的方法
下面小編就為大家分享一篇thinkphp中U方法按路由規(guī)則生成url的方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-03-03