I want to access the files inside the zip file and send it back to Django backend

I want to access the file extracted from a zip file and post it to the database, this code is for extracting the files, I don't know how to access the files:

      var reader = new FileReader();
      reader.onload = function (ev) {
        JSZip.loadAsync(ev.target.result).then(function (zip) {
          var zipfile_names = new Array();
          var shpfile_names = new Array();
          var BreakException = {};
          var allFiles = new Array();
          try {
            zip.forEach(function (relativePath, zipEntry) {
              $("#div1").hide();
              document.getElementById("div2").hidden = false;

              $("#div2").show();
              //CONTROL THAT FILE EXTENSIONS ARE ALL SHAPEFILE VALID
              var allowed_shp_extensions = ['shp', 'shx', 'dbf', 'sbn', 'sbx', 'fbn', 'fbx', 'ain', 'aih', 'atx', 'ixs', 'mxs', 'prj', 'xml', 'cpg']
              var shpext = ['shp']
              // check the zipEntry is a file
              if ((zipEntry.name.includes('.') == true) && (zipEntry.dir == false)) {
                var split_filename = zipEntry.name.split('.')
                if (allowed_shp_extensions.includes(split_filename[split_filename.length - 1]) == true) {
                  var name_extract = zipEntry.name.replace(/^.*[\\\/]/, '')
                  zipfile_names.push(name_extract)
                }
                allFiles.push(zipEntry.name);
              };});```
Back to Top