js根据后缀判断文件是图片还是视频
程序员文章站
2022-03-10 21:55:50
...
function getFileType(name) {
if(!name) return false;
var imgType=["gif", "jpeg", "jpg", "bmp", "png"];
var videoType=["avi","wmv","mkv","mp4","mov","rm","3gp","flv","mpg","rmvb"];
if(RegExp("\.(" + imgType.join("|") + ")$", "i").test(name.toLowerCase())) {
return 'image';
} else if(RegExp("\.(" + videoType.join("|") + ")$", "i").test(name.toLowerCase())) {
return 'video';
} else {
return false;
}
}
上一篇: python判断文件类型
下一篇: vue获取链接后参数