Skip to content

Instantly share code, notes, and snippets.

@BetterProgramming
Created August 27, 2019 14:53
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 BetterProgramming/52e001327d00a675f0157f07cc3f0737 to your computer and use it in GitHub Desktop.
Save BetterProgramming/52e001327d00a675f0157f07cc3f0737 to your computer and use it in GitHub Desktop.
export const imageFileFilter = (req, file, callback) => {
if (!file.originalname.match(/\.(jpg|jpeg|png|gif)$/)) {
return callback(new Error('Only image files are allowed!'), false);
}
callback(null, true);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment