Wciąż staram się owinąć wokół tego głowę.
Mogę poprosić użytkownika o wybranie pliku (lub nawet wielu) za pomocą wejścia pliku:
<form>
<div>
<label>Select file to upload</label>
<input type="file">
</div>
<button type="submit">Convert</button>
</form>
I mogę złapać submitwydarzenie za pomocą <fill in your event handler here>. Ale kiedy już to zrobię, jak wysłać plik przy użyciu fetch?
fetch('/files', {
method: 'post',
// what goes here? What is the "body" for this? content-type header?
}).then(/* whatever */);
Content-Type: multipart/form-dataw nagłówku żądania