var maxsize = 20*1024*1024;//20M
var errMsg = "上传的文件不能超过20M!!!";
var tipMsg = "您的浏览器暂不支持计算上传文件的大小,确保上传文件不要超过20M,建议使用360、FireFox、Chrome浏览器。";
var pwdMsg = "请输入文件密码";
var browserCfg = {};
var ua = window.navigator.userAgent;

if (ua.indexOf("MSIE")>=1){
browserCfg.ie = true;
}else if(ua.indexOf("Firefox")>=1){
browserCfg.firefox = true;
}else if(ua.indexOf("Chrome")>=1){
browserCfg.chrome = true;
}
function checkfile(){

}
$("#sub_btn").click(function(){
try{
var obj_file = document.getElementById("upload_file");
if(obj_file.value==""){
$("#upload_error_text").text("请先选择上传文件");
$("#upload_error").show();
return;
}
var filesize = 0;
if(browserCfg.firefox || browserCfg.chrome ){
filesize = obj_file.files[0].size;
}else if(browserCfg.ie){
var obj_img = document.getElementById('tempimg');
obj_img.dynsrc=obj_file.value;
filesize = obj_img.fileSize;
}else{
$("#upload_error_text").text(tipMsg);
$("#upload_error").show();
return;
}
if(filesize==-1){
$("#upload_error_text").text(tipMsg);
$("#upload_error").show();
return;
}else if(filesize>maxsize){
$("#upload_error_text").text(errMsg);
$("#upload_error").show();

return;
}else{
if($("#file_pwd").val()==''){
$("#upload_error_text").text(pwdMsg);
$("#upload_error").show();
return;
}

alert("您的文件密码很重要,请牢记!!!");
$("#form_").submit();
}
}catch(e){
console.log(e);
return false;
}
});