Я пытаюсь загрузить images
с url
моего локального хоста
Мой код здесь
<head>
<script src="Stuk-jszip-9fb481a/dist/jszip.js"></script>
<script>
window.onload = function() {
var zip = new JSZip();
var a = document.querySelector("a");
var urls = ["http://localhost/cce/assests/images//save_img.png"];
function request(url) {
return new Promise(function(resolve) {
var httpRequest = new XMLHttpRequest();
httpRequest.open("GET", url);
httpRequest.onload = function() {
zip.file(url, this.responseText);
resolve()
}
httpRequest.send()
})
}
Promise.all(urls.map(function(url) {
return request(url)
}))
.then(function() {
console.log(zip);
zip.generateAsync({
type: "blob"
})
.then(function(content) {
a.download = "folder" + new Date().getTime();
a.href = URL.createObjectURL(content);
a.innerHTML = "download " + a.download;
});
})
}
</script>
</head>
<body>
<a href="" download>download</a>
</body>
но вместо него создается папка http
для хранения изображения
отображается на консоли, как
http:/
:
ZipObject {name: "http:/", dir: true, date: Tue Sep 11 2018 18:39:38 GMT+0530 (India Standard Time), comment: null, unixPermissions: null, …}
http://localhost/
:
ZipObject {name: "http://localhost/", dir: true, date: Tue Sep 11 2018 18:39:38 GMT+0530 (India Standard Time), comment: null, unixPermissions: null, …}