Skip to content

Commit

Permalink
Add file type indicator to file input test
Browse files Browse the repository at this point in the history
  • Loading branch information
n0samu committed Nov 19, 2023
1 parent 2754367 commit 248e22b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions fileInputTest2.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@

<h1>File Input Test</h1>
<input type="file" accept=".*" id="local-file" />
<div id="type"></div>

<script type="text/javascript">
const fileInput = document.getElementById("local-file");
const txtDiv = document.getElementById("type");
fileInput.addEventListener('change', (e) => {
if (fileInput.files.length > 0) {
const file = fileInput.files[0];
txtDiv.textContent = file.type;
}
});
</script>

</body>
</html>

0 comments on commit 248e22b

Please sign in to comment.