//验证文件格式和大小
//obj是对象,i是下标
function doUpload(obj,i){
var imgType=".bmp.jpg.jepg.png.gjf";
var a=obj. value;
if(a !="" && a !=null ){
var index1=a.lastIndexOf(".");
var vType=a.substring(index1+1,a.length). toLowerCase();//后缀名
if(imgType.indexOf(vType)<0){
obj.value="";
alert("您上传的第"+(i+1)+"个附件格式不正确,请重新上传!");
return false;
}else{
var fileSize = 0;
var isIE = /msie/i. test(navigator . userAgent) && !window . opera; ;
if (isIE && !obj.files) {
var filePath = obj.value ;
var fileSystem = new ActiveX0bject("Scripting. FileSystem0bject");var file = fileSystem. GetFile (filePath);fileSize = file.Size;}else {
fileSize = obj. files[0].size;
fileSize=Math. round( fileSize/1024*100)/100; //単 位カKBif(fileSize>1024){
if(fileSize>1024){
alert("第"+(i+1)+"个附件不能超过1M,请重新上传!");
return false;
}else{
return true;
}
}
}
}
return true;
}