2021-08-31 19:07:19 +05:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
|
|
|
|
<head>
|
|
|
|
<meta charset="utf-8">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
|
|
|
<title>File Storage</title>
|
|
|
|
<style>
|
|
|
|
* {
|
|
|
|
font-family: Verdana;
|
|
|
|
font-size: 16px;
|
2021-09-22 11:20:46 +05:00
|
|
|
color: #abb2bf;
|
2021-08-31 19:07:19 +05:00
|
|
|
margin: .5em;
|
|
|
|
padding: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
html {
|
|
|
|
margin: 0;
|
|
|
|
padding: 0;
|
|
|
|
height: 100%
|
|
|
|
}
|
|
|
|
|
|
|
|
body {
|
2021-09-22 11:20:46 +05:00
|
|
|
background-color: #282c34;
|
2021-08-31 19:07:19 +05:00
|
|
|
display: flex;
|
2021-09-22 11:20:46 +05:00
|
|
|
justify-content: space-between;
|
2021-08-31 19:07:19 +05:00
|
|
|
flex-wrap: nowrap;
|
|
|
|
flex-direction: column;
|
|
|
|
height: 100%;
|
|
|
|
margin: 0;
|
|
|
|
padding: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
a {
|
|
|
|
text-decoration: none;
|
2021-09-22 11:20:46 +05:00
|
|
|
color: #61afef;
|
2021-08-31 19:07:19 +05:00
|
|
|
margin: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
svg, img {
|
|
|
|
vertical-align: middle;
|
|
|
|
width: 1em;
|
|
|
|
height: 1em;
|
|
|
|
}
|
|
|
|
|
2021-09-22 11:20:46 +05:00
|
|
|
header, footer {
|
|
|
|
flex-grow: 0;
|
|
|
|
background-color: #353b45;
|
2021-08-31 19:07:19 +05:00
|
|
|
padding: .5em;
|
|
|
|
margin: 0;
|
|
|
|
display: flex;
|
|
|
|
justify-content: space-between;
|
|
|
|
align-items: center;
|
|
|
|
}
|
|
|
|
|
2021-09-22 11:20:46 +05:00
|
|
|
main {
|
|
|
|
flex-grow: 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
header {
|
|
|
|
border-bottom: 1px solid #3e4451;
|
|
|
|
}
|
|
|
|
|
2021-08-31 19:07:19 +05:00
|
|
|
footer {
|
2021-09-22 11:20:46 +05:00
|
|
|
border-top: 1px solid #3e4451;
|
|
|
|
font-size: 75%;
|
2021-08-31 19:07:19 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
h1 {
|
|
|
|
margin-top: 1em;
|
|
|
|
font-size: 150%;
|
|
|
|
}
|
|
|
|
|
|
|
|
table {
|
|
|
|
border-collapse: collapse;
|
|
|
|
width: 100%;
|
|
|
|
margin: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
tr:hover {
|
2021-09-22 11:20:46 +05:00
|
|
|
background-color: #353b45;
|
2021-08-31 19:07:19 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
th, td {
|
2021-09-22 11:20:46 +05:00
|
|
|
border: 1px solid #3e4451;
|
2021-08-31 19:07:19 +05:00
|
|
|
padding: 0.5em;
|
|
|
|
}
|
|
|
|
|
|
|
|
td:nth-child(2), td:nth-child(3) {
|
|
|
|
width: 10em;
|
|
|
|
text-align: right;
|
|
|
|
}
|
|
|
|
|
|
|
|
th {
|
2021-09-22 11:20:46 +05:00
|
|
|
background-color: #353b45;
|
2021-08-31 19:07:19 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
form {
|
|
|
|
width: calc(100% - 1em);
|
|
|
|
}
|
|
|
|
|
|
|
|
form > input {
|
|
|
|
width: calc(100% - 2em);
|
|
|
|
padding: .5em;
|
|
|
|
}
|
|
|
|
|
|
|
|
button {
|
|
|
|
padding: .5em;
|
|
|
|
margin: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
pre {
|
|
|
|
margin: 0;
|
|
|
|
font-family: monospace;
|
|
|
|
}
|
|
|
|
|
|
|
|
input[type="file"] {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
label {
|
2021-09-22 11:20:46 +05:00
|
|
|
border-radius: 0.25em;
|
|
|
|
background-color: #61afef;
|
2021-08-31 19:07:19 +05:00
|
|
|
margin: 0;
|
|
|
|
padding: .5em;
|
|
|
|
cursor: pointer;
|
2021-09-22 11:20:46 +05:00
|
|
|
color: #ffffff;
|
|
|
|
text-shadow: 1px 1px 1px #000;
|
2021-08-31 19:07:19 +05:00
|
|
|
}
|
|
|
|
|
2021-09-01 10:11:36 +05:00
|
|
|
svg {
|
|
|
|
margin: 0;
|
2021-09-22 11:20:46 +05:00
|
|
|
vertical-align: middle;
|
2021-09-01 10:11:36 +05:00
|
|
|
}
|
2021-08-31 19:07:19 +05:00
|
|
|
</style>
|
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
|
|
|
<header>
|
2021-09-22 11:20:46 +05:00
|
|
|
<span><svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 15 15" fill="#61afef" stroke="#353b45"><circle cx="7.5" cy="7.5" r="5" fill="none" stroke="#61afef"/><circle cx="3" cy="10" r="2"/><circle cx="12" cy="10" r="2"/><circle cx="7.5" cy="2.5" r="2"/></svg> File Storage</span>
|
2021-08-31 19:07:19 +05:00
|
|
|
<label>
|
|
|
|
<input id="file-uploader" type="file" id="upload-button">
|
|
|
|
Загрузить файл
|
|
|
|
</label>
|
|
|
|
</header>
|
|
|
|
<main>
|
|
|
|
<table>
|
|
|
|
<col width="*">
|
|
|
|
<col width="0">
|
|
|
|
<col width="0">
|
|
|
|
<tr>
|
2021-09-22 11:20:46 +05:00
|
|
|
<th>Имя файла</th>
|
2021-08-31 19:07:19 +05:00
|
|
|
<th>Размер</th>
|
|
|
|
<th>Дата</th>
|
|
|
|
</tr>
|
|
|
|
{{range .}} <tr>
|
|
|
|
<td><a href="/download?filename={{.Name}}">{{.Name}}</a></td>
|
|
|
|
<td><pre>{{.Size}}</pre></td>
|
|
|
|
<td>{{.Date}}</td>
|
|
|
|
</tr>
|
|
|
|
{{end}} </table>
|
|
|
|
</main>
|
|
|
|
</body>
|
|
|
|
|
|
|
|
</html>
|
|
|
|
<script type="text/javascript">
|
|
|
|
function myProgressHandler(event) {
|
|
|
|
var p = Math.floor(event.loaded/event.total*100);
|
|
|
|
document.querySelector("label").innerHTML = 'Загрузка: ' + p + '%...';
|
|
|
|
}
|
|
|
|
|
|
|
|
function myOnLoadHandler(event) {
|
|
|
|
const response = event.currentTarget;
|
|
|
|
if (response.status != 200) {
|
|
|
|
alert('Ошибка при загрузке файла:\n' + response.responseText);
|
|
|
|
}
|
|
|
|
document.querySelector("label").innerHTML = 'Загрузка завершена.';
|
|
|
|
location.reload();
|
|
|
|
}
|
|
|
|
|
|
|
|
document.getElementById("file-uploader").addEventListener('change', (e) => {
|
|
|
|
var file = document.getElementById("file-uploader").files[0];
|
|
|
|
var formData = new FormData;
|
|
|
|
formData.append('file', file);
|
|
|
|
var ajax = new XMLHttpRequest;
|
|
|
|
ajax.upload.addEventListener("progress", myProgressHandler, false);
|
|
|
|
ajax.addEventListener('load', myOnLoadHandler, false);
|
|
|
|
ajax.open('POST', '/upload', true);
|
|
|
|
ajax.send(formData);
|
|
|
|
});
|
|
|
|
</script>
|