简体   繁体   English

如何创建文件夹,该文件夹中的文件,压缩文件夹(以zip或rar文件形式)并将其使用Javascript上传到桌面?

[英]How to create folder, files in this folder, compress folder (in zip or rar file) and upload this to the desktop with Javascript?

For a web application, an user must be able to export an html file with css stylesheet of choice (proposed by the application) on his desktop. 对于Web应用程序,用户必须能够在其桌面上导出具有选择的CSS样式表(由应用程序提出)的html文件。

A unique button for export : on click, a "Save as" dialog window appears for choose a destination on desktop. 唯一的导出按钮:单击后,将出现“另存为”对话框窗口,用于在桌面上选择目标。 The file must have extension .zip (or .rar) and he contains html and css files. 该文件的扩展名为.zip(或.rar),并且包含html和css文件。

How can I do this (without library) ? 我该如何做(没有库)? Thanks. 谢谢。

You can use the JSZip library to do this https://stuk.github.io/jszip/ 您可以使用JSZip库执行此操作https://stuk.github.io/jszip/

var zip = new JSZip();
zip.file("Hello.txt", "Hello World\n");
var img = zip.folder("images");
img.file("smile.gif", imgData, {base64: true});
var content = zip.generate({type:"blob"});
saveAs(content, "example.zip");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM