Spaces:
Sleeping
Sleeping
DmitrMakeev
commited on
Commit
•
b62e348
1
Parent(s):
0753094
Update up_page.html
Browse files- up_page.html +123 -7
up_page.html
CHANGED
@@ -2,14 +2,130 @@
|
|
2 |
<html lang="en">
|
3 |
<head>
|
4 |
<meta charset="UTF-8">
|
5 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
</head>
|
7 |
<body>
|
8 |
-
<div id="
|
9 |
-
|
10 |
-
|
11 |
-
<
|
12 |
-
|
13 |
-
</
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
</body>
|
15 |
</html>
|
|
|
2 |
<html lang="en">
|
3 |
<head>
|
4 |
<meta charset="UTF-8">
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<title>File Upload</title>
|
7 |
+
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/toastify-js/src/toastify.min.css">
|
8 |
+
<style>
|
9 |
+
body {
|
10 |
+
font-family: Arial, sans-serif;
|
11 |
+
text-align: center;
|
12 |
+
background-color: #f0f0f0;
|
13 |
+
margin: 0;
|
14 |
+
padding: 0;
|
15 |
+
}
|
16 |
+
h1 {
|
17 |
+
background-color: #4CAF50;
|
18 |
+
color: white;
|
19 |
+
padding: 20px;
|
20 |
+
margin: 0;
|
21 |
+
border-bottom: 2px solid #388E3C;
|
22 |
+
}
|
23 |
+
button[type="submit"] {
|
24 |
+
color: white;
|
25 |
+
background-color: #4CAF50;
|
26 |
+
border: none;
|
27 |
+
cursor: pointer;
|
28 |
+
padding: 10px 20px;
|
29 |
+
font-size: 16px;
|
30 |
+
border-radius: 5px;
|
31 |
+
margin-top: 20px;
|
32 |
+
}
|
33 |
+
button[type="submit"]:hover {
|
34 |
+
background-color: #388E3C;
|
35 |
+
}
|
36 |
+
#mediaContainer {
|
37 |
+
margin-top: 20px;
|
38 |
+
display: flex;
|
39 |
+
justify-content: center;
|
40 |
+
align-items: center;
|
41 |
+
flex-direction: column;
|
42 |
+
max-width: 100%;
|
43 |
+
height: auto;
|
44 |
+
}
|
45 |
+
#mediaContainer img, #mediaContainer video {
|
46 |
+
max-width: 100%;
|
47 |
+
height: auto;
|
48 |
+
object-fit: contain;
|
49 |
+
}
|
50 |
+
#imageUrl {
|
51 |
+
margin-top: 20px;
|
52 |
+
font-size: 16px;
|
53 |
+
color: #333;
|
54 |
+
cursor: pointer;
|
55 |
+
text-decoration: underline;
|
56 |
+
}
|
57 |
+
#progressBarContainer {
|
58 |
+
width: 80%;
|
59 |
+
margin: 20px auto;
|
60 |
+
background-color: #ddd;
|
61 |
+
border-radius: 13px;
|
62 |
+
padding: 3px;
|
63 |
+
}
|
64 |
+
#progressBar {
|
65 |
+
width: 0%;
|
66 |
+
height: 20px;
|
67 |
+
background-color: #4CAF50;
|
68 |
+
border-radius: 10px;
|
69 |
+
text-align: center;
|
70 |
+
line-height: 20px;
|
71 |
+
color: white;
|
72 |
+
}
|
73 |
+
</style>
|
74 |
</head>
|
75 |
<body>
|
76 |
+
<div id="mediaContainer">
|
77 |
+
<!-- Media content will be displayed here -->
|
78 |
+
</div>
|
79 |
+
<div id="progressBarContainer">
|
80 |
+
<div id="progressBar">0%</div>
|
81 |
+
</div>
|
82 |
+
<div id="imageUrl" onclick="copyToClipboard(this)">Кликните после загрузки, для получения ссылки на сохранённый файл.</div>
|
83 |
+
<form id="uploadForm" enctype="multipart/form-data" method="post" action="/up_page">
|
84 |
+
<input type="file" name="file" accept=".html">
|
85 |
+
<input type="text" name="filename" placeholder="имя файла(маршрут)">
|
86 |
+
<button type="submit">Загрузить</button>
|
87 |
+
</form>
|
88 |
+
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/toastify-js"></script>
|
89 |
+
<script>
|
90 |
+
document.getElementById('uploadForm').addEventListener('submit', function(event) {
|
91 |
+
event.preventDefault();
|
92 |
+
var formData = new FormData(this);
|
93 |
+
var request = new XMLHttpRequest();
|
94 |
+
request.open('POST', '/up_page');
|
95 |
+
request.upload.addEventListener('progress', function(event) {
|
96 |
+
if (event.lengthComputable) {
|
97 |
+
var percentComplete = (event.loaded / event.total) * 100;
|
98 |
+
document.getElementById('progressBar').style.width = percentComplete + '%';
|
99 |
+
document.getElementById('progressBar').innerText = Math.round(percentComplete) + '%';
|
100 |
+
}
|
101 |
+
}, false);
|
102 |
+
request.addEventListener('load', function(event) {
|
103 |
+
var response = event.target.responseText;
|
104 |
+
var fullUrl = response.split('saved to ')[1];
|
105 |
+
document.getElementById('imageUrl').innerText = fullUrl;
|
106 |
+
document.getElementById('progressBar').style.width = '0%';
|
107 |
+
document.getElementById('progressBar').innerText = '0%';
|
108 |
+
// Сохранение ссылки в локальное хранилище
|
109 |
+
localStorage.setItem('fileUrl', fullUrl);
|
110 |
+
}, false);
|
111 |
+
request.send(formData);
|
112 |
+
});
|
113 |
+
|
114 |
+
function copyToClipboard(element) {
|
115 |
+
var tempInput = document.createElement("input");
|
116 |
+
tempInput.value = element.innerText;
|
117 |
+
document.body.appendChild(tempInput);
|
118 |
+
tempInput.select();
|
119 |
+
document.execCommand("copy");
|
120 |
+
document.body.removeChild(tempInput);
|
121 |
+
Toastify({
|
122 |
+
text: "Ссылка скопирована в буфер обмена",
|
123 |
+
duration: 3000,
|
124 |
+
gravity: "top",
|
125 |
+
position: "center",
|
126 |
+
backgroundColor: "#4CAF50",
|
127 |
+
}).showToast();
|
128 |
+
}
|
129 |
+
</script>
|
130 |
</body>
|
131 |
</html>
|