Skip to content

Instantly share code, notes, and snippets.

@kosamari
Last active August 29, 2015 14:04
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 kosamari/37e7d2923539c9a0dc46 to your computer and use it in GitHub Desktop.
Save kosamari/37e7d2923539c9a0dc46 to your computer and use it in GitHub Desktop.
script for file extention verification
/*
script for file extention verification
*/
var path = 'path/to/file';
var imageExt = ['jpeg','jpg','png','gif','tiff']; //specify allowed file extentions
var fileExt = path.split('.');
var checkExist = imageExt.indexOf(fileExt[fileExt.length-1]); // -1 if the file extention does not exist in imageExt
if (checkExist === -1){
console.log('File type not supported, please use '+ imageExt);
return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment