Skip to content

Instantly share code, notes, and snippets.

@MichalZalecki
Last active May 5, 2017 10:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MichalZalecki/59880981502583e23db6d50c03afc0f9 to your computer and use it in GitHub Desktop.
Save MichalZalecki/59880981502583e23db6d50c03afc0f9 to your computer and use it in GitHub Desktop.
Filter uploaded files by file type
export default function validateType(accepts) {
const typeExps = accepts.split(/ *, */).map(type => new RegExp(type));
return file => Boolean(typeExps.find(exp => exp.test(file.type)));
}
// function onChange({ target }) {
// const acceptedFiles = target.files.filter(validateType("images/*, application/pdf"));
// }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment