document.getElementById("zipInput").addEventListener("change", handleFile);
function handleFile(event) {
const file = event.target.files[0];
const reader = new FileReader();
reader.onload = function (e) {
const base64String = e.target.result.split(",")[1]; // 获取 Base64 编码
document.body.innerHTML =
"Base64 编码:" + base64String.length + "TTTEST\n" + base64String;
// for (let i = 0; i < base64String.length; i += 1000) {
// console.log(base64String.split(0, i));
// }
// 触发下载 ZIP
// createZipFromBase64(base64String, file.name);
};
reader.readAsDataURL(file); // 以 Base64 方式读取文件
}
// function createZipFromBase64(base64String, fileNa me) {
// const zip = new JSZip();
// zip.file(fileName, base64String, { base64: true });
// zip.generateAsync({ type: "blob" }).then(function(content) {
// const link = document.createElement("a");
// link.href = URL.createObjectURL(content);
// link.download = fileName;
// link.click();
// });
// }
// const base64=123
<input type="file" id="zipInput">
<button onclick="convertAndDownload()">转换</button>