0
我创建了一个函数来下载一个用于多个文件的压缩文件以用于共享点。如何在IE中使用jszip下载Zip文件?
function create_zip() {
var zip = new JSZip();
$.each(filePathArray, function (i, path) {
var filename = path; //"file" + i +".txt";
var filee = path.substring(path.lastIndexOf('/') + 1);
var fileURL = appweburl + "/_api/SP.AppContextSite(@target)/web/GetFileByServerRelativeUrl('" + filename + "')/[email protected]='" + hostweburl + "'";//$('#file').attr('href');
var request = $.ajax({
url: fileURL,
type: "GET",
contentType: "text/plain",
mimeType: 'text/plain; charset=x-user-defined' // <-[1]
});
request.done(function (data) {
//var filee = "MoveFiles" + count + ".txt";
zip.file(filee, data, { binary: true }); // <- [2]
//count++;
vfilecount++;
console.log(vfilecount);
console.log(vfilecount);
if (count == vfilecount) {
zip.generateAsync({ type: "base64" }).then(function (data) {
location.href = "data:application/zip;base64," + data;
});
}
});
});
}
现在这段代码适用于Chrome和Mozilla,但不适用于IE。 请以任何方式提出建议。