mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 17:10:23 +00:00
LibWeb: Add multipart/form-data demo to formdata.html
This commit is contained in:
parent
1120011de4
commit
c9ee1ad5ae
Notes:
sideshowbarker
2024-07-16 21:56:51 +09:00
Author: https://github.com/kennethmyhra Commit: https://github.com/SerenityOS/serenity/commit/c9ee1ad5ae Pull-request: https://github.com/SerenityOS/serenity/pull/18169 Reviewed-by: https://github.com/linusg ✅
1 changed files with 21 additions and 0 deletions
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue