-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
34 lines (33 loc) · 1.01 KB
/
index.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<form method="post" name="zone-importer-with-ntl-form" id="z" data-netlify="true">
<p>
<label>Zone file</label>
<input type="file" name="zone" accept=".txt">
</p>
<p>
<button type="submit">Submit</button>
</p>
</form>
<script>
document.querySelector("form").addEventListener("submit", handleSubmit);
const handleSubmit = (e) => {
e.preventDefault()
let myForm = document.getElementById('z');
let formData = new FormData(myForm)
fetch('/', {
method: 'POST',
headers: { "Content-Type": "multipart/form-data" },
body: new URLSearchParams(formData).toString()
})
.then(() => console.log('Form successfully submitted'))
.catch((error) => alert(error))
}
</script>
</body>
</html>