<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="js/jquery-2.1.3.min.js"></script>
<script type="text/javascript">
function change() {
var obj = document.getElementById("upload");
var len = obj.files.length;
for (var i = 0; i < len; i++) {
var temp = obj.files[i].name;
var fileExt=(/[.]/.exec(temp)) ? /[^.]+$/.exec(temp.toLowerCase()) : '';
alert(fileExt);
}
}
</script>
</head>
<body>
<input id="upload" οnchange="change();" type="file" value="点击上传图片" multiple="multiple" />
</body>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="js/jquery-2.1.3.min.js"></script>
<script type="text/javascript">
function change() {
var obj = document.getElementById("upload");
var len = obj.files.length;
for (var i = 0; i < len; i++) {
var temp = obj.files[i].name;
var fileExt=(/[.]/.exec(temp)) ? /[^.]+$/.exec(temp.toLowerCase()) : '';
alert(fileExt);
}
}
</script>
</head>
<body>
<input id="upload" οnchange="change();" type="file" value="点击上传图片" multiple="multiple" />
</body>
</html>
参考了http://www.cnblogs.com/sntetwt/p/4167426.html