Skip to content

Can we zip folders? #233

Discussion options

You must be logged in to vote

Here's an example of how to achieve this with zip.js

<input type=file multiple webkitdirectory id="files">
<script src="https://cdn.jsdelivr.net/npm/@zip.js/zip.js@2.2.22/dist/zip.min.js"></script>
<script>
  files.onchange = async event => {
    document.body.innerHTML = "";  
    const zipWriter = new zip.ZipWriter(new zip.Data64URIWriter("application/zip"));
    await Promise.all(Array.from(event.target.files).map(async file => {
      await zipWriter.add(file.webkitRelativePath, new zip.BlobReader(file));
      document.body.innerHTML += " - " + file.webkitRelativePath + "<br>";
    }));
    document.body.innerHTML += "<br>";
    const link = document.createElement("a");
    link.href = 

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by gildas-lormeau
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant