文章出處
文章列表
zip.js是什么
zip.js的github項目地址:http://gildas-lormeau.github.io/zip.js/
通過zip.js封裝一個能在網頁端生成zip文件的插件, 直接在網頁中創建包含文件夾和文件的壓縮包,也可以自定義名字并下載;
如何使用:
1:引用zip.js
2:引用jQuery;
3:并引用封裝的ZipArchive.js ,(因為zip.js的api使用起來比較繁瑣,所以自己封裝實現了這個插件)
4:引用mime-types.js;
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title></title> <script src="http://gildas-lormeau.github.io/zip.js/demos/zip.js"></script> <script src="http://gildas-lormeau.github.io/zip.js/demos/mime-types.js"></script> <script src="http://apps.bdimg.com/libs/jquery/1.9.0/jquery.js"></script> <script src="http://sqqihao.github.io/codes/zipjs/deflate.js"></script> <script src="http://files.cnblogs.com/files/diligenceday/ZipArchive.js"></script> <script> zip.useWebWorkers = false; </script> </head> <body> <script> var z = new ZipArchive; z.addFile("a/a.txt", "aaaaaaacontent"); z.addFile("aaaa.txt", "aaaaaaaccccc"); z.export("nono"); </script> </body> </html>
DEMO在后面:文件下載下來, 文件夾的格式如下:
參考:github的demo:http://sqqihao.github.io/codes/zipjs/zipjs.html
作者: NONO
出處:http://www.cnblogs.com/diligenceday/
QQ:287101329
文章列表
全站熱搜