Skip to content

Instantly share code, notes, and snippets.

@MichalZalecki
Last active May 5, 2017 10:03
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
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