本文实例讲述了javascript实现校验文件上传控件。分享给大家供大家参考。具体如下:
该javascript校验文件上传控件代码可检测上传文件的类型是否是图片
logo1');
var fileName = fup.value;
var ext = fileName.substring(fileName.lastIndexOf('.') + 1);
if(ext == "gif" || ext == "GIF" || ext == "JPEG" || ext == "jpeg" || ext == "jpg" || ext == "JPG" || ext == "png" || ext == "PNG")
{
return true;
}
else
{
alert("Upload JPG,JPEG,PNG,GIF images only");
fup.focus();
return false;
}
}
onchange="Checkfiles()"
希望本文所述对大家的javascript程序设计有所帮助。
原文链接:https://www.f2er.com/js/54681.html