테스트 사이트 - 개발 중인 베타 버전입니다

게시판 글쓰기 시 파일첨부 수정 사항

· 12년 전 · 7446 · 3

목차

  1. 들어가기
  2. 소스비교
  3. 차이점

들어가기

그누보드4s 개발에 있어서 가장 큰 난제 중 하나는, 자바스크립트 off 환경에 대해 얼마나, 어떻게, 어디까지 대응할 것인가? 에 대한 것이었습니다.
'여전히' 자바스크립트 off 환경에 대한 의문이 남아 있는 상태이지만, 우리는 대응 가능한 것에 대하여 지속적인 대응을 늦추지 말자는 입장을 견지하고 있습니다.
자바스크립트 off 대응에 대한 결과물 중 하나가 바로 게시판 글쓰기 시 파일첨부입니다.

소스비교

기존코드, write.skin.php

<? if ($is_file) { ?>
<tr>
    <td class=write_head>
        <table cellpadding=0 cellspacing=0>
        <tr>
            <td class=write_head style="padding-top:10px; line-height:20px;">
                파일첨부<br> 
                <span onclick="add_file();" style="cursor:pointer;"><img src="<?=$board_skin_path?>/img/btn_file_add.gif"></span> 
                <span onclick="del_file();" style="cursor:pointer;"><img src="<?=$board_skin_path?>/img/btn_file_minus.gif"></span>
            </td>
        </tr>
        </table>
    </td>
    <td style='padding:5 0 5 0;'><table id="variableFiles" cellpadding=0 cellspacing=0></table><?// print_r2($file); ?>
        <script type="text/javascript">
        var flen = 0;
        function add_file(delete_code)
        {
            var upload_count = <?=(int)$board[bo_upload_count]?>;
            if (upload_count && flen >= upload_count)
            {
                alert("이 게시판은 "+upload_count+"개 까지만 파일 업로드가 가능합니다.");
                return;
            }

            var objTbl;
            var objRow;
            var objCell;
            if (document.getElementById)
                objTbl = document.getElementById("variableFiles");
            else
                objTbl = document.all["variableFiles"];

            objRow = objTbl.insertRow(objTbl.rows.length);
            objCell = objRow.insertCell(0);

            objCell.innerHTML = "<input type='file' class='ed' name='bf_file[]' title='파일 용량 <?=$upload_max_filesize?> 이하만 업로드 가능'>";
            if (delete_code)
                objCell.innerHTML += delete_code;
            else
            {
                <? if ($is_file_content) { ?>
                objCell.innerHTML += "<br><input type='text' class='ed' size=50 name='bf_content[]' title='업로드 이미지 파일에 해당 되는 내용을 입력하세요.'>";
                <? } ?>
                ;
            }

            flen++;
        }

        <?=$file_script; //수정시에 필요한 스크립트?>

        function del_file()
        {
            // file_length 이하로는 필드가 삭제되지 않아야 합니다.
            var file_length = <?=(int)$file_length?>;
            var objTbl = document.getElementById("variableFiles");
            if (objTbl.rows.length - 1 > file_length)
            {
                objTbl.deleteRow(objTbl.rows.length - 1);
                flen--;
            }
        }
        </script></td>
</tr>
<tr><td colspan=2 height=1 bgcolor=#e7e7e7></td></tr>
<? } ?>

수정코드, write.skin.php

<? for ($i=0; $is_file && $i<$file_count; $i++) { ?>
<tr>
    <th scope="row">파일 #<?=$i+1?></th>
    <td>
        <input type="file" name="bf_file[]" title="파일첨부 <?=$i+1?> :  용량 <?=$upload_max_filesize?> 이하만 업로드 가능" class="frm_file frm_input">
        <? if ($is_file_content) { ?>
        <input type="text" name="bf_content[]" value="<? echo $file[$i]['bf_content']; ?>" title="파일 설명을 입력해주세요." class="frm_file frm_input" size="50">
        <?}?>
        <? if($w == 'u' && $file[$i]['file']) { ?>
        <input type="checkbox" id="bf_file_del<?=$i?>" name="bf_file_del[<? echo $i; ?>]" value="1"> <label for="bf_file_del<?=$i?>"><? echo $file[$i]['source'].'('.$file[$i]['size'].')'; ?> 파일 삭제</label>
        <? } ?>
    </td>
</tr>
<? } ?>

차이점

기존 파일첨부는 파일첨부 입력칸이 기본 2개가 출력된 상태에서 사용자가 추가/삭제 버튼을 눌러, 입력칸을 추가/삭제할 수 있었습니다.(게시판 관리자에서 설정된 한도 내) 또한 파일 업로드 갯수가 0 일 경우, 무한대로 파일을 첨부할 수 있었습니다.
그누보드4s 에서는 게시판 관리자에서 설정된 파일 업로드 갯수만큼 파일첨부 입력칸이 출력되며, 0 일 경우 파일첨부 기능이 동작하지 않도록 수정되었습니다.

이 과정에서 write.skin.php 내 파일첨부 관련 스크립트가 모두 삭제되었습니다.

댓글 작성

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

로그인하기

댓글 3개

설명 감사합니다. ^^

파일 업로드 갯수 - 게시물 한건당 업로드 할 수 있는 파일의 최대 개수 (0 이면 제한 없음)

그렇다면 관리자 설정에 이 문구가 변경되어야 맞는 거네요?
0이면 미사용.. 이렇게요?
12년 전
4.0b3 에서 안내문구 수정 업데이트 예정입니다.
12년 전
아항

게시글 목록

번호 제목
1084
1083
1080
1074
1068
1064
1056
1048
1037
1029
1025
1022
1019
1014
1013
1012
1003
1002
997
992
986
982
973
962
952
950
947
945
942
938