html:
<div style=”width:100%;” border=”0″>
<form method=”post” id=”uploadForm” enctype=”multipart/form-data” method=”post”>
<div class=”formdiv”>
<div>
<input class=”easyui-filebox” name=”uploadFile” id=”uploadFileid” data-options=”required:true,validType:’suffix[\’xls,xlsx\’]’,prompt:’请选择文件’,buttonText:’ 选 择 文 件’,onChange:function c(){change(this)}” style=”width:100%”>
</div>
</div>
</div>
js:
function change(_obj){
var tempFile = $(“#uploadFileid”);
var value=tempFile.filebox(‘getValue’);
// 取后缀名
var ext=value.substring(value.lastIndexOf(“.”)+1).toLowerCase();
if(ext!=’xls’){
if(ext!=’xlsx’){
$.messager.alert(“消息提示”, “文件格式不对!请重新上传”, “error”);
return;
}
}
//取file
var file = $(_obj).context.ownerDocument.activeElement.files[0]
}