s

첨부파일 확장자 체크 [정규식]

파일 첨부 시 첨부파일 확장자가 이미지 파일인지 체크 하는 스크립트 입니다.

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=euc-kr">
<title>확장자 검사</title>
<script language=javascript>

function checkExt()
{
var IMG_FORMAT = "\.(bmp|gif|jpg|jpeg|png)$"; //문서만 첨부하게 하려면 이 부분 바꿔주시면 되겠죠? ^^

if((new RegExp(IMG_FORMAT, "i")).test(document.form1.text1.value)) return true;

alert("이미지 파일만 첨부하실 수 있습니다. ");

return false;
}

</script>
</head>
<body>
<form name="form1" method="post" onsubmit="return checkExt()" encType="multipart/form-data">
<input type="file" name="text1">
<input type="submit">
</form>
</body>
</html>

|

댓글 3개

댓글을 작성하시려면 로그인이 필요합니다. 로그인

팁게시판

디자인과 관련된 유용한 정보를 공유하세요. 질문은 상단의 QA에서 해주시기 바랍니다.

+
제목 글쓴이 날짜 조회
12년 전 조회 3,710
12년 전 조회 3,114
12년 전 조회 3,956
12년 전 조회 4,341
12년 전 조회 1,573
12년 전 조회 2,695
12년 전 조회 2,690
12년 전 조회 1,228
12년 전 조회 1,255
12년 전 조회 8,381
12년 전 조회 1,489
12년 전 조회 3,734
12년 전 조회 6,319
12년 전 조회 1,540
12년 전 조회 1,128
12년 전 조회 1,300
12년 전 조회 3,277
12년 전 조회 1,057
12년 전 조회 1,801
12년 전 조회 1,232
12년 전 조회 893
12년 전 조회 1,382
12년 전 조회 2,081
12년 전 조회 1,365
12년 전 조회 1,247
🐛 버그신고