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。 請以任何方式提出建議。