【发布时间】:2019-07-23 22:59:26
【问题描述】:
到目前为止,我正在尝试使用 javascript 从多个 URL 下载多个文件,但我尝试了多个选项,但它仅适用于 1 个 URL。
我有一个 URL 数组,需要在浏览器中启动多个下载。
$(fileUrls).each(function(_index, fileUrl: any) {
let tempElement: any;
tempElement = document.createElement("A");
tempElement.href = fileUrl;
tempElement.download = fileUrl.substr(fileUrl.lastIndexOf("/") + 1);
document.body.appendChild(tempElement);
tempElement.click();
document.body.removeChild(tempElement);
});
也尝试过使用
$(fileUrls).each(function (_index, fileUrl: any) {
window.location.href = fileUrl;
});
但它仅适用于 1 个 URL 其余调用失败并在浏览器中显示以下警告消息
资源解释为文档,但使用 MIME 类型 application/octet-stream 传输
【问题讨论】:
标签: javascript jquery typescript