其实之前我也对文件类型做了判断,在此一并与大家共享一下:
function pstn2ngnMigration(){
if (dbfFileNameValidate()){
if(fileSizeValidate()){
if(confirm("do you want to execute migration ?")){
lockSystem('please waiting...',false)
setTimeout("dbfFileMigration()",3000);
}
}
}
}
//判断是否是.DBF文件,是返回true
function dbfFileNameValidate()
{
var filestr = document.all.UploadFile.value;
if(filestr==""){
alert("Please select a migration file!");
document.all.UploadFile.focus();
return false;
}else if(filestr.toLowerCase().lastIndexOf(".dbf")==-1){
alert("Please select a file with DBF extension !");
document.all.UploadFile.focus();
return false;
}
return true;
}
//条件成立,提交
function dbfFileMigration()
{
document.Uploadform.action="MigrationSendOrder.jsp";
document.Uploadform.submit();
unlockSystem();
}
//上传文件大小限制
function fileSizeValidate()
{
var filestr = document.all.UploadFile.value;
var fso,f;
fso=new ActiveXObject("Scripting.FileSystemObject");
f=fso.GetFile(filestr);
if(f.size>5*1024*1024){
alert("The size of .dbf is more than 5M");
return false;
}
return true;
}
页面代码如下: