//判断上传文件格式是否满足条件
function isPicture(fileName){
if(fileName!=null && fileName !=""){
//lastIndexOf如果没有搜索到则返回为-1
if (fileName.lastIndexOf(".")!=-1) {
var fileType = (fileName.substring(fileName.lastIndexOf(".")+1,fileName.length)).toLowerCase();
var suppotFile = new Array();
suppotFile[0] = "jpg";
suppotFile[1] = "gif";
suppotFile[2] = "bmp";
suppotFile[3] = "png";
suppotFile[4] = "jpeg";
for (var i =0;i<suppotFile.length;i++) {
if (suppotFile[i]==fileType) {
return true;
} else{
continue;
}
}
//alert("文件类型不合法,只能是jpg、gif、bmp、png、jpeg类型!");
return false;
} else{
//alert("文件类型不合法,只能是 jpg、gif、bmp、png、jpeg 类型!");
return false;
}
}
JS判断、控制文件上传的类型
精选 转载chen2009277025 博主文章分类:javascript
文章标签 shell linux 文章分类 运维
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
js--精准判断上传文件类型
js--精准判断上传文件类型
上传 文件类型 解决方案
















