-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck.html
42 lines (39 loc) · 1.35 KB
/
check.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>File Upload Test</title>
</head>
<body>
<h1>File Upload Test</h1>
<form id="uploadForm" enctype="multipart/form-data">
<input type="file" name="file" id="fileInput" />
<button type="button" id="uploadButton">Upload</button>
</form>
<div id="response"></div>
<script>
document.addEventListener("DOMContentLoaded", () => {
const uploadForm = document.getElementById("uploadForm");
const fileInput = document.getElementById("fileInput");
const uploadButton = document.getElementById("uploadButton");
const responseDiv = document.getElementById("response");
uploadButton.addEventListener("click", () => {
const formData = new FormData(uploadForm);
fetch("http://localhost:5000/upload/file", {
method: "POST",
body: formData,
})
.then((response) => response.json())
.then((data) => {
responseDiv.innerHTML = JSON.stringify(data, null, 2);
})
.catch((error) => {
console.error(error);
responseDiv.innerHTML = "Error uploading file.";
});
});
});
</script>
</body>
</html>