you have two options
1) pass a base64 string as part of a json payload.
2) use the FormData object as the post content
<form id="form">
<input type="file" id="file" name="file">
<button type="button">Upload</button>
</form>
<script>
if (!document.getElementById("file"))
{
alert("Select File first");
return;
}
var url = "/postfile";
var data = new FormData(document.getElementById("form"));
fetch(url, {
method: "POST",
data: data
});
</script>
.