1, support Google does not support IE
<script type= "Text/javascript"
src= "${pagecontext.request.contextpath}/foundation/common/js/jquery-1.11.1.min.js" >
</script>
<script type= "Text/javascript"
src= "${pagecontext.request.contextpath}/foundation/common/js/jquery-1.11.1.js" >
</script>
function Uploadf () {
var idcardorphotofile=$ ("#idCardOrPhotoFile"). Val ();
var iopstr=idcardorphotofile.substr (Idcardorphotofile.lastindexof (".")). toUpperCase ();
var ff = $ (": File");
if (iopstr!= ". JPG ") {
Alert ("ID card picture type can only be. jpg type, please re-upload!") ");
Ff.after (Ff.clone (). Val (""));
Ff.remove ();
return false;
}
var files = $ (' input[name= ' Idcardorphotofile "]). Prop (' files ');//Get to File list
Alert ("1");
var _file = files[0];
Alert ("2");
alert (_file.size);
if (!_file) {
return;}
if (_file.size>60*1024) {
Alert ("id picture cannot exceed 60KB");
Ff.after (Ff.clone (). Val (""));
Ff.remove ();
return false;
}
}
<input type= "File" style= "width:300px"
Name= "Idcardorphotofile" id= "Idcardorphotofile" onchange= "UPLOADF ()"/>
JS and jquery foreground check file size