Skip to content

Commit bdc401b

Browse files
authored
Update index.html
1 parent dc1df8c commit bdc401b

File tree

1 file changed

+24
-40
lines changed

1 file changed

+24
-40
lines changed

index.html

Lines changed: 24 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,29 @@
11
<!DOCTYPE html>
22
<html lang="en">
3-
<meta charset="UTF-8">
4-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
5-
<title>Dear Photos</title>
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+
</head>
68
<body>
7-
<h1>Dear Photos</h1>
8-
<input type="file" id="upload">
9-
<button onclick="sendFile()">Upload</button>
10-
<p id="status"></p>
11-
12-
<script>
13-
function sendFile() {
14-
var fileInput = document.getElementById("upload");
15-
var statusText = document.getElementById("status");
16-
17-
if (!fileInput.files.length) {
18-
statusText.innerText = "Choose a file!";
19-
return;
20-
}
21-
22-
var file = fileInput.files[0];
23-
24-
var reader = new FileReader();
25-
reader.onload = function () {
26-
var filedata = encodeURIComponent(reader.result.split(",")[1]);
27-
var filename = encodeURIComponent(file.name);
28-
29-
// Создаём JSONP-запрос
30-
var script = document.createElement("script");
31-
script.src = `https://quick-dragonfly-85.deno.dev/upload?callback=handleResponse&filename=${filename}&filedata=${filedata}`;
32-
document.body.appendChild(script);
33-
};
34-
35-
reader.readAsDataURL(file);
36-
statusText.innerText = "Sending...";
37-
}
38-
39-
function handleResponse(data) {
40-
document.getElementById("status").innerText = data.message;
41-
}
42-
</script>
43-
9+
<h1>Upload File</h1>
10+
11+
<form id="uploadForm" action="https://quick-dragonfly-85.deno.dev/upload" method="post" enctype="multipart/form-data" target="hiddenFrame">
12+
<input type="file" name="file" id="upload">
13+
<button type="submit">Upload</button>
14+
</form>
15+
16+
<iframe name="hiddenFrame" style="display: none;"></iframe>
17+
<p id="status"></p>
18+
19+
<script>
20+
document.getElementById("uploadForm").onsubmit = function () {
21+
document.getElementById("status").innerText = "Sending...";
22+
};
23+
24+
function handleResponse(message) {
25+
document.getElementById("status").innerText = message;
26+
}
27+
</script>
4428
</body>
4529
</html>

0 commit comments

Comments
 (0)