Last active
August 29, 2015 14:04
-
-
Save kosamari/37e7d2923539c9a0dc46 to your computer and use it in GitHub Desktop.
script for file extention verification
This file contains hidden or 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
/* | |
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