-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
36 lines (35 loc) · 1.08 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
35
36
<!DOCTYPE html>
<html>
<head>
<title>Post Repro</title>
<script>
document.addEventListener('DOMContentLoaded', ()=> {
document.querySelector('#test').addEventListener('click', testFunction);
document.querySelector('#test2').addEventListener('click', testFunction2);
});
function testFunction(e) {
var formData = new FormData();
const file_input = document.querySelector('#files');
formData.append("myFile", file_input.files[0]);
var request = new XMLHttpRequest();
request.open("POST", "./");
request.send(formData);
}
function testFunction2(e) {
const myForm = document.querySelector('#myForm');
var formData = new FormData(myForm);
var request = new XMLHttpRequest();
request.open("POST", "./");
request.send(formData);
}
</script>
</head>
<body bgcolor="#E6E6FA">
<div>Pick a file</div>
<form id="myForm" method="post" target="_blank">
<input id="files" type="file" multiple="">
<input id="test" type="button" value="Test">
<input id="test2" type="button" value="Test (using Form)">
</form>
</body>
</html>