<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>
<body>
<form id="form1">
<div>
<input type="file" name="file" id="longzhoufeng" />
<input type="button" name="abc" value="测试" onclick="fileName();" />
</div>
</form>
</body>
</html>
<script type="text/javascript">
function fileName() {
var long = document.getElementById("longzhoufeng").value;
var pos=long.lastIndexOf("\\");
var aaa=long.substring(pos+1);
alert(aaa)
var bbb=aaa.lastIndexOf(".");
var ccc=aaa.substring(bbb+1);
alert(ccc)
var strFileName=long.replace(/^.+?\\([^\\]+?)(\.[^\.\\]*?)?$/gi,"$1");
alert(strFileName)
alert("扩展名:"+ccc+" "+",文件名:"+strFileName+" "+",扩展名的文件名:"+aaa)
}
</script>