Update online.html
Browse files- online.html +37 -13
online.html
CHANGED
|
@@ -1,14 +1,38 @@
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
</
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
</
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
<!DOCTYPE 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>Upload Image</title>
|
| 7 |
+
</head>
|
| 8 |
+
<body>
|
| 9 |
+
<h1>Upload Image</h1>
|
| 10 |
+
<form id="uploadForm" enctype="multipart/form-data" method="post" action="/upload">
|
| 11 |
+
<input type="file" name="photo">
|
| 12 |
+
<button type="submit">Upload</button>
|
| 13 |
+
</form>
|
| 14 |
+
<div id="message"></div>
|
| 15 |
+
<script>
|
| 16 |
+
document.getElementById('uploadForm').addEventListener('submit', function(event) {
|
| 17 |
+
event.preventDefault();
|
| 18 |
+
var formData = new FormData(this);
|
| 19 |
+
fetch('/upload', {
|
| 20 |
+
method: 'POST',
|
| 21 |
+
body: formData
|
| 22 |
+
})
|
| 23 |
+
.then(response => {
|
| 24 |
+
if (response.ok) {
|
| 25 |
+
return response.text();
|
| 26 |
+
}
|
| 27 |
+
throw new Error('Network response was not ok.');
|
| 28 |
+
})
|
| 29 |
+
.then(data => {
|
| 30 |
+
document.getElementById('message').innerText = data;
|
| 31 |
+
})
|
| 32 |
+
.catch(error => {
|
| 33 |
+
document.getElementById('message').innerText = 'Error: ' + error.message;
|
| 34 |
+
});
|
| 35 |
+
});
|
| 36 |
+
</script>
|
| 37 |
+
</body>
|
| 38 |
+
</html>
|