javascript - How to use js API to upload files?

I am still trying to wrap my head around it.

I can have the user select the file (or even multiple) with the file input:

    <label>Select file to upload</label>
    <input type="file">
  <button type="submit">Convert</button>

And I can catch the submit event using <fill in your event handler here>. But once I do, how do I send the file using fetch?

fetch('/files', {
  method: 'post',
  // what goes here? What is the "body" for this? content-type header?
}).then(/* whatever */);
This question and all comments follow the "Attribution Required."

All Answers

Answers Loading...
Leave a Reply
You must be logged in to post a answer.