Pages

2014년 2월 21일 금요일

[JAVASCRIPT] JavaScript 파일 확장자 체크

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
    // 파일 확장자 체크
    function fileCheck(file_gubun, file_nm){
        // 허용 가능 확장자 선택
        if(file_gubun == "service" && /.*\.(gif)|(jpeg)|(jpg)|(png)$/.test(file_nm.toLowerCase())){
            return false;
        }
        if(file_gubun == "ctn" && /.*\.(text)|(txt)$/.test(file_nm.toLowerCase()) ){
            return false;
        }        
        if(file_gubun == "bbs" && /.*\.(text)|(txt)$/.test(file_nm.toLowerCase()) ){
            return false;
        }
        if(file_gubun == "frmwr" && /.*\.(text)|(txt)|(exe)|(bin)|(zip)$/.test(file_nm.toLowerCase()) ){
            return false;
        }
        if(file_gubun == "excel" && /.*\.(xls)$/.test(file_nm.toLowerCase()) ){
            return false;
        }
        return true;
    }

댓글 없음:

댓글 쓰기