var Sys = {};
if(navigator.userAgent.indexOf("MSIE")>0) {
Sys.ie=true;
}
if(isFirefox=navigator.userAgent.indexOf("Firefox")>0){
Sys.firefox=true;
}
if(isFirefox=navigator.userAgent.indexOf("'Chrome")>0){
Sys.firefox=true;
}
if(isFirefox=navigator.userAgent.indexOf("'Opera")>0){
Sys.firefox=true;
}
//清空上传文件大小超过5M给提示不让上传
function checkFileChange(obj) {
var filesize = 0;
if(Sys.firefox){
filesize = obj.files[0].fileSize;
}else if(Sys.ie){
var filePath = obj.value;
var image=new Image();
image.dynsrc=filePath;
filesize=image.fileSize;
}
if (filesize>5*1024*1024)//大于5M
{
window.alert('More than 5M,Please Try again!');
clearFileInput(obj);
return false;
}
}
//清空验证后的fileupload控件内容
function clearFileInput(file){
var form=document.createElement('form');
document.body.appendChild(form);
var pos=file.nextSibling;
form.appendChild(file);
form.reset();
pos.parentNode.insertBefore(file,pos);
document.body.removeChild(form);
}