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

본문 바로가기

정보공유

일반글
그누보드팁

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

페이지 정보

게시물QR코드

본문

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();

        }

    }

}



 

댓글목록

등록된 댓글이 없습니다.

  • Addr.부산광역시 동구 중앙대로 319, 9층 L4호(초량동, 부산YMCA빌딩) Email. gnuwiz@naver.com
  • BR. 625-68-00172 TRC. 2019-부산해운대-1186 TEL. 0507-1382-2790
All rights reserved.