django에서 "링크"배열로 정적 파일을 가져와야합니다 ...
var links = [
'/static/uploads/fth/FthAgg.xlsx',
'/static/uploads/fth/FthCon.xlsx'
];
이것은 html입니다.
{% load static %}
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="{% static 'css/pages/fthpage.css' %}">
<script src="{% static 'js/downloads.js' %}"></script>
<title></title>
</head>
<body>
<h1 class="header_h1">FTH Page</h1>
<button onclick="downloadAll(window.links)">Test me!</button>
</a>
</body>
</html>
그래도 작동하지 않습니다. https 링크를 넣으려고하면 작동합니다. 나중에 하나의 버튼으로 이러한 파일을 동시에 다운로드 할 수 있도록 이렇게합니다.
다음은 내 자바 스크립트 파일입니다. https://pastebin.com/0sCTav8G
다음은 내 html 템플릿입니다. https://pastebin.com/yvz2AL0M
function downloadAll(links)
{
for (i = 0, len = links.length; i < len; i++) {
var link = links[i];
var a = document.createElement("a");
var file = 'file'+ i + '.xlsx';
a.setAttribute('href', 'data:text/plain;charset=utf-8, '
+ link);
a.setAttribute('download', file);
a.click();
}
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다