二級table,選擇打包文件,打包zip下載

最近客戶要求實現table變成二級的選擇,並且打包zip下載到本地功能,先看效果圖

這次使用了2個組件:

1、layui的treeTable

2、php_zip.dll

記錄一下避免下次坑,注意:

1、treeTable好像不支持layui的分頁,如果可以的話,各位兄弟姐妹幫忙留意指導指導

2、php_zip.dll下載地址,我選擇1.13.0,試了幾個5.4版本的,最後 php_zip-1.13.0-5.4-ts-vc9-x86.zip 是匹配我的PHP版本的。

地址:https://windows.php.net/downloads/pecl/releases/zip/

3、配置(1)PHP.INI 增加  extension=php_zip.dll
             (2)php_zip.dll 拷貝到php/ext 目錄下面
             (3)/htdocs文件夾下 新建down文件夾,存放壓縮文件
             (4)PHP.INI  修改  max_execution_time=0    就是永不過期,我是壓縮視頻文件一個都好幾百M,
             (5)重啓網站 服務

4、沒有使用以下代碼下載,因爲壓縮的文件很大,讀取文件都要好久好久,瀏覽器會卡死

header("Cache-Control: public");

header("Content-Description: File Transfer");

header('Content-disposition: attachment; filename='.basename($zipname)); //文件名 

header("Content-Type: application/zip"); //zip格式的 

header("Content-Transfer-Encoding: binary"); //告訴瀏覽器,這是二進制文件 

header('Content-Length: '. filesize($zipname)); //告訴瀏覽器,文件大小 

readfile($zipname);

解決方法:直接把路徑回傳給js,  直接window.open(url_path);  

5, treetable下載地址  https://codeload.github.com/whvcse/treetable-lay/zip/master

6、歡迎感興趣同學留言諮詢