JSFiddle - React, Tailwind, and code Playground
HTML
<input id="file" type="file" />
JavaScript
const url = 'https://cloud.squidex.io/api/apps/my-tests/assets';
const token = 'YOUR_TOKEN';
const input = document.getElementById('file');
input.addEventListener('change', function () {
const file = input.files[0];
const formData = new FormData();
formData.append('file', file);
fetch(url, {
method: 'POST',
headers: {
Authorization: `Bearer ${token}`
},
body: formData
});
});