Extracting zipped files using JSZIP in javascript

后端 未结 3 1395
南笙
南笙 2021-02-04 13:21

In my webpage, a user is supposed to upload a zipped file. Within the zipped file are 2 files: another zip file and a txt file. On my server, after receiving the zip, I want to

3条回答
  •  梦如初夏
    2021-02-04 14:06

    This is a working version I am using:

    var jsZip = require('jszip')
    jsZip.loadAsync(file).then(function (zip) {
      Object.keys(zip.files).forEach(function (filename) {
        zip.files[filename].async('string').then(function (fileData) {
          console.log(fileData) // These are your file contents      
        })
      })
    })
    

    You can get most of the information you need from http://stuk.github.io/jszip/documentation/examples.html but it's a little hard to get in one place, you have to look around a bit.

提交回复
热议问题