JSFiddle - React, Tailwind, and code Playground
by Nihar Raote
HTML
<input id="word-file" type="file" accept=".doc,.docx" />
<button id="btn">
Click here
</button>
JavaScript
let file = null;
let data = new FormData();
document.querySelector("#word-file").addEventListener("change", () => {
file = document.getElementById("word-file").files[0];
data.append("word", file);
})
document.getElementById("btn").addEventListener("click", () => {
console.log(data.get('word').text());
})