[英]Need a JavaScript Simple Code For Zip A Folder
my web server is a simple html server.我的 web 服务器是一个简单的 html 服务器。 there is no node.js,no php so i wanna make a zip file by js of the directory "/public_html/alpha" mainly i wanna zip the alpha folder there is no node.js,no php so i wanna make a zip file by js of the directory "/public_html/alpha" mainly i wanna zip the alpha folder
I tried the jszip.js and zip.js but didnt work.why i dont know..我尝试了 jszip.js 和 zip.js 但没用。为什么我不知道..
Here is the code:这是代码:
<html>
<head>
<script src="/jszip.js"></script>
</head>
<body>
<p>Works on firefox, chrome , opera >= 15 and IE >= 10 (but NOT in compatibility view).</p>
<button id="blob" class="btn btn-primary">click to download</button>
<script>
var zip = new JSZip();
zip.file("readme.txt", "alpha");
jQuery("#blob").on("click", function () {
zip.generateAsync({type:"blob"}).then(function (blob) { // 1) generate the zip file
saveAs(blob, "hello.zip"); // 2) trigger the download
}, function (err) {
jQuery("#blob").text(err);
});
});
</script>
</body>
</html>
This Code dont even give any result.该代码甚至没有给出任何结果。
Server link: For Check Click Here服务器链接:检查点击这里
Add jquery on header在 header 上添加 jquery
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
then in script make it like this然后在脚本中使它像这样
$(document).ready(function(){
$("#blob").click(function(){
// bla bla bla your code
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.