I’m trying to post a large binary object via a <form>
element. There is an old version that posts it using a b64
encoded string in a <input type="hidden">
field, but the payload data gets much larger than the web server allows.
As a solution, I’m trying to put the raw data in binary via a <input type="file">
field instead, so I can avoid the b64
inflation. Is this even possible?
The current code looks like this:
function submitToServer(evt) {
evt?.preventDefault?.()
const myForm = document.querySelector('form#RequestModal'),
data = new FormData(myForm)
let fetchData = [
fetch('...', {method, body, headers...}),
... Other fetches...
]
Promise.all(fetchData)
.then([clientRes, tokenRes, otherData] => {
...
})
.catch(E => {
...
})
}
As you might have guessed, the <form>
element has a number of hidden input fields that are filled programmatically. I’m trying to replace these fields with file input fields (hidden by css).