JSFiddle - React, Tailwind, and code Playground

by netnguyen270

HTML

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
  <div class="vb-content">
    <h1>Can select only .png and .jpg files</h1>
    <input type="file" id="file-uploader" accept=".jpg, .png" multiple>
    <p>Upload files and see the output in browser console</p>
  </div>
</body>
</html>

CSS

html {
  min-height: 100vh;
}

body {
  background: #000000;
  color: #FFFFFF;
}

.vb-content {
  display: flex;
  justify-content: center;
  flex-direction: column;
  align-items: center;
  font-family: 'Roboto Mono', monospace;
}

JavaScript

const fileUploader = document.getElementById('file-uploader');

fileUploader.addEventListener('change', (event) => {
  const files = event.target.files;
  console.log('files', files);
});