Last active
May 5, 2017 10:03
-
-
Save MichalZalecki/59880981502583e23db6d50c03afc0f9 to your computer and use it in GitHub Desktop.
Filter uploaded files by file type
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
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