String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
My JSP 'index.jsp' starting pagefunction validateFileType(){
var obj = document.getElementById("files");
if(obj.value == "" || obj.value == null){
alert("请选择上传文件!");
return ;
}
//获取文件的后缀名的位置
var index = obj.value.lastIndexOf(".");
if(index == -1){
alert("上传文件类型不对!");
return;
}
//截取后缀名
var type = obj.value.substring(index+1);
if(type != "jpg" && type != "png" && type != "jpeg"){
alert("请选择图片文件上传!");
return;
}else{
alert("您对了!");
}
}