[관리] 게시판 첨부파일 업로드시 이미지 파일만 허용하기

그누위즈 쪽지보내기 포인트선물 메일보내기 자기소개 아이디로 검색 전체게시물 그누보드 팁 21-03-10 15:57 40,132

092bcd1dbc222142a3719e3fcc57907a_1615359333_7924.png

게시판 첨부파일 업로드시 이미지 파일만 허용하는 방법입니다.

이미지 외 다른 파일을 등록하면 위와 같이 알림창이 뜹니다.


<!-- 해당스킨/write.skin.php -->

<input type="file" name="bf_file[]" id="bf_file_<?php echo $i+1 ?>" title="파일첨부 <?php echo $i+1 ?> : 용량 <?php echo $upload_max_filesize ?> 이하만 업로드 가능" class="frm_file">


파일 첨부 부분에서

class="frm_file" 에 imagext 를 추가

class="frm_file imgext"


적용 후

<input type="file" name="bf_file[]" id="bf_file_<?php echo $i+1 ?>" title="파일첨부 <?php echo $i+1 ?> : 용량 <?php echo $upload_max_filesize ?> 이하만 업로드 가능" class="frm_file imgext">


## 참고 ##

imgext 클래스가 실행되는 곳은 js/wrest.js 파일에 있습니다.


// 이미지 확장자

function wrestImgExt(fld)

{

    if (!wrestTrim(fld)) return;


    var pattern = /\.(gif|jpg|png)$/i; // jpeg 는 제외

    if(!pattern.test(fld.value)){

        if(wrestFld == null){

            wrestMsg = wrestItemname(fld)+" : 이미지 파일이 아닙니다.\n.gif .jpg .png 파일만 가능합니다.\n";

            wrestFld = fld;

            fld.select();

        }

    }

}



 

추천 0 비추천 0
  • 페이스북으로 보내기
  • 트위터로 보내기
  • 구글플러스로 보내기
  • 밴드 보내기
  • 블로그 보내기
  • 폴라 보내기
  • 카카오스토리 보내기
  • 텔레그램 보내기
  • 텀블러 보내기
댓글 0

그누보드 팁

RSS
번호 제목 글쓴이 날짜 추천 비추천
상단으로