How to zip a img from file input with JSZIP

I try to zip a file from a file-input, but it does not work. How can I do it by using java script?

var input = document.getElementById("id1");
const filereader = new FileReader();
filereader.onload = function() {
  zip.file("picture.png", filereader.result, {binary: true});
}
filereader.readAsDataURL(input.files[0]);
<input type="file" id="id1" style="border-radius: 0.1px; width: 40%;" accept="image/*">

33 thoughts on “How to zip a img from file input with JSZIP”

Leave a Comment