<div>
<h1>Only accepts JPG and PNG.</h1>
<input type="file" id="file-uploader" accept=".jpg, .png" multiple>
<p>Multiple files.</p>
<p id="feedback"></p>
</div>
html {
height: 100%;
}
body {
background: white;
color: black;
}
div {
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
font-family: 'Roboto Mono', monospace;
}
const fileUploader = document.getElementById('file-uploader');
fileUploader.addEventListener('change', (event) => {
const files = event.target.files;
console.log('files', files);
// show the upload feedback
const feedback = document.getElementById('feedback');
const msg = `${files.length} file(s) uploaded successfully!`;
feedback.innerHTML = msg;
});
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.