LibWeb: Add multipart/form-data demo to formdata.html

This commit is contained in:
Kenneth Myhra 2023-04-02 23:05:35 +02:00 committed by Linus Groh
parent 1120011de4
commit c9ee1ad5ae
Notes: sideshowbarker 2024-07-16 21:56:51 +09:00

View file

@ -2,6 +2,14 @@
<html>
<head>
<title>FormData</title>
<style>
.code-block {
background-color: grey;
color: lightgrey;
border-radius: 2px;
padding: 5px;
}
</style>
<script>
function log(s) {
document.getElementById("out").innerHTML += `${s}\n`;
@ -41,6 +49,15 @@
log(`Entry: ${entry[0]}, ${entry[1]}`);
}
}
function postMultipartFormData() {
let form = document.getElementById("form1");
let formData = new FormData(form);
let xhr = new XMLHttpRequest;
xhr.open("POST", "http://localhost:8000");
xhr.send(formData);
}
</script>
</head>
<body>
@ -67,5 +84,9 @@
<button onclick="dumpFormContents()">Test FormData Features</button>
<div style="padding-top: 30px; padding-left: 5px">To test multipart/form-data start a simple echo server:</div>
<div style="padding-left: 10px; padding-bottom: 10px"><span class="code-block">while true; do printf 'HTTP/1.1 200 OK\n' | nc -Nl 8000; done</span></div>
<button onclick="postMultipartFormData()">Test multipart/form-data</button>
<pre id="out"></pre>
</body>