<script>
function check(){
var type=form1.upfile.value.match(/^(.*)(/.)(.{1,8})$/)[3];
type=type.toUpperCase();
if(type=="XLS" || type=="DOC" || type=="HTML" || type=="TXT"){
return true;
}
else{
alert("上传类型有误");
return false;
}
}
</script>
<form enctype="multipart/form-data" οnsubmit="return(check())" name="form1">
<input type="file" name="upfile">
<input type="submit" value="上传">
</form>