Created
March 21, 2022 05:10
-
-
Save JoeThunyathep/88fa0a19db745c7e04b98c878c99324d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<input type="file" id="fs" multiple> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fileSelect = document.getElementById('fs'); | |
fileSelect.addEventListener('change', (event) => { | |
const fileList = event.target.files; | |
for (const file of fileList) { | |
// Constructing Meta Data if support. | |
const name = file.name ? file.name : 'NOT SUPPORTED'; | |
const type = file.type ? file.type : 'NOT SUPPORTED'; | |
const size = file.size ? `${file.size/1000} KB` : 'NOT SUPPORTED'; | |
// Log the filename/ type/ size in the browser console | |
console.log({file, name, type, size}); | |
// Continue doing something with files... | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment