1
0
mirror of https://github.com/actix/examples synced 2024-12-02 18:02:22 +01:00
examples/forms/multipart-s3/src/index.html

36 lines
987 B
HTML
Raw Normal View History

<!-- TODO: fix me -->
2022-08-01 02:17:59 +02:00
<html>
<head><title>S3 Upload Test</title></head>
<body>
<form target="/" method="post" enctype="multipart/form-data" id="s3UploadForm">
<label>
Namespace:
<input type="text" name="namespace" value="default" />
</label>
<input type="file" multiple name="file" />
<input type="button" value="Submit" onclick="upload()"></button>
</form>
2022-08-01 02:17:59 +02:00
<script>
async function upload() {
var $form = document.getElementById('s3UploadForm');
var $files = document.getElementsByName('file')[0];
2022-08-01 02:17:59 +02:00
const formData = new FormData();
2022-08-01 02:17:59 +02:00
formData.append("namespace", $form.namespace.value);
2022-08-01 02:17:59 +02:00
for (const file in $files.files) {
formData.append("file", file);
}
2022-08-01 02:17:59 +02:00
await fetch(new URL(window.location), {
method: 'POST',
formData
});
}
2022-08-01 02:17:59 +02:00
</script>
</body>
2022-08-01 02:17:59 +02:00
</html>