JSFiddle - React, Tailwind, and code Playground
by rowntreerob
HTML
<label>Select file to upload</label>
<input type="file" id="files" name="files[]">
JavaScript
// This will upload the file after having read it
const url1 = 'https://{$appName}.osc-fr1.scalingo.io/awsvid/'
let status;
const upload = (file) => {
fetch(url1, {
method: 'POST',
headers: {"Origin":"https://jsfiddle.net",
"Content-Type": " video/mp4",
"Access-Control-Request-Headers":
"Origin, Content-Type"},
body: file // This is your file object
}).then(
response => response.json()
).then(
json => {console.log(json)
console.log(status);}
).catch((err) => {
console.error(err);
});
};
// Event handler executed when a file is selected
const onSelectFile = (evt) => { upload(evt.target.files[0]) };
document.getElementById('files').addEventListener(
'change', onSelectFile, false);