I have a Vue app where user uploads a zip file and I want to pick certain files from the zip (which includes many files and folders) and post them to the server. I know this is much easier to do so in the backend but for my project I need this to happen in the frontend.
I tried using JSZip where I can see the content of the zip but can’t pick the wanted files so I can include them in the formdata to post to the server.
`JSZip.loadAsync(this.uploadZip).then((zip) => {
zip.forEach((relativePath, zipEntry) => {
console.log(zipEntry);
if (
zipEntry.name ==
“1ST_FILE_TO_PICK” ||
zipEntry.name ==
“2ND_FILE_TO_PICK”
) {
formData.append(“file”, zipEntry);
}
});
});
// then the Axios to post the formdata
`
this.uploadZip = user’s uploaded zip file from the event.target
with the above code the the required files doesn’t go thru the request and the backend throws an error which the files are not there. Any way to solve this?
Njteh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.