자바스크립트를 이용한 파일확장자 구하기
예1)
var fname="C:\\test\\text.txt";
var s=fname.lastIndexOf("\\");
var m=fname.lastIndexOf(".");
var e=fname.length;
var filename=fname.substring(s+1,m);
var extname=fname.substring(m+1,e);
alert(filename+"_"+extname);
예2)
var fname=document.all.myfile.value;
var arr=("file:///"+fname.replace(/ /gi,"%20").replace(/\\/gi,"/")).split("/");
alert(arr[arr.length-1]);
예3)
function getExtension() {
var file = document.getElementsByName("upfile").item(0);
var extension = file.value.replace( /%/,"%25").substr(file.value.replace( /%/,"%25").lastIndexOf(".")+1).toUpperCase();
return extension;
}