글쓸때 첨부파일을 일정개수 미리 입력창 보여주기 (Ver.2) > 그누4 팁자료실

그누4 팁자료실

그누보드4와 관련된 팁을 여러분들과 함께 공유하세요.
나누면 즐거움이 커집니다.

글쓸때 첨부파일을 일정개수 미리 입력창 보여주기 (Ver.2) 정보

글쓸때 첨부파일을 일정개수 미리 입력창 보여주기 (Ver.2)

본문

# 첨부파일을 일정개수(갯수)만큼 미리 입력창 보여주기
Ver.1 : http://sir.co.kr/bbs/board.php?bo_table=g4_tiptech&wr_id=11828
Ver.2 : 첨부파일 설명글을 추가할수 있도록 코드 추가

스킨 / wirte.skin.php 의 아래 내용을

<? if ($is_file) { ?>
<tr>
    <td style='padding-left:20px; height:30px;'><table cellpadding=0 cellspacing=0><tr><td style=" padding-top: 10px;">· 파일 <span onclick="add_file();" style='cursor:pointer; font-family:tahoma; font-size:12pt;'>+</span> <span onclick="del_file();" style='cursor:pointer; font-family:tahoma; font-size:12pt;'>-</span></td></tr></table></td>
    <td style='padding:5 0 5 0;'><table id="variableFiles" cellpadding=0 cellspacing=0></table><?// print_r2($file); ?>
        <script language="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>
<? } ?>


아래의 내용으로 교체합니다.
2013-05-19 첨부파일 설명글을 추가할수 있도록 코드 추가합니다.
2013-05-19 첨부파일 허용개수 확인해서 적용

        <?php if ($is_file) { // 첨부파일 있을때 ?>
        <tr>
          <td style='padding-left:20px; height:30px;'>· 파일1 <?php //echo (int)$board[bo_upload_count]; ?></td>
          <td><input class="box" type="file" name='bf_file[]' /><?php if(!$file[0][href]){ echo " (필수입력)"; }
            if($file[0][href])
              echo "<input type='checkbox' name='bf_file_del[0]' value='1'><a href='{$file[0][href]}'>{$file[0][source]}({$file[0][size]})</a> 파일 삭제";
            if ($is_file_content)
              echo "<br /><input type='text' class=ed size=50 name='bf_content[0]' value='".addslashes(get_text($file[0][bf_content]))."' title='업로드 이미지 파일에 해당 되는 내용을 입력하세요.' />";
          ?></td>
        </tr>
        <?php if ((int)$board[bo_upload_count] >= 2 || (int)$board[bo_upload_count] == 0) { ?>
        <tr>
          <td style='padding-left:20px; height:30px;'>· 파일2</td>
          <td><input class="box" type="file" name='bf_file[]' /><?php
            if($file[1][href])
              echo "<input type='checkbox' name='bf_file_del[1]' value='1'><a href='{$file[1][href]}'>{$file[1][source]}({$file[1][size]})</a> 파일 삭제";
            if ($is_file_content)
              echo "<br /><input type='text' class=ed size=50 name='bf_content[1]' value='".addslashes(get_text($file[1][bf_content]))."' title='업로드 이미지 파일에 해당 되는 내용을 입력하세요.' />";
          ?></td>
        </tr>
        <?php } ?>
        <?php if ((int)$board[bo_upload_count] >= 3 || (int)$board[bo_upload_count] == 0) { ?>
        <tr>
          <td style='padding-left:20px; height:30px;'>· 파일3</td>
          <td><input class="box" type="file" name='bf_file[]' /><?php
            if($file[2][href])
              echo "<input type='checkbox' name='bf_file_del[2]' value='1'><a href='{$file[2][href]}'>{$file[2][source]}({$file[2][size]})</a> 파일 삭제";
            if ($is_file_content)
              echo "<br /><input type='text' class=ed size=50 name='bf_content[2]' value='".addslashes(get_text($file[2][bf_content]))."' title='업로드 이미지 파일에 해당 되는 내용을 입력하세요.' />";
          ?></td>
        </tr>
        <?php } ?>
        <?php if ((int)$board[bo_upload_count] >= 4 || (int)$board[bo_upload_count] == 0) { ?>
        <tr>
          <td style='padding-left:20px; height:30px;'>· 파일4</td>
          <td><input class="box" type="file" name='bf_file[]' /><?php
            if($file[3][href])
              echo "<input type='checkbox' name='bf_file_del[3]' value='1'><a href='{$file[3][href]}'>{$file[3][source]}({$file[3][size]})</a> 파일 삭제";
            if ($is_file_content)
              echo "<br /><input type='text' class=ed size=50 name='bf_content[3]' value='".addslashes(get_text($file[3][bf_content]))."' title='업로드 이미지 파일에 해당 되는 내용을 입력하세요.' />";
          ?></td>
        </tr>
        <?php } ?>
        <?php if ((int)$board[bo_upload_count] >= 5 || (int)$board[bo_upload_count] == 0) { ?>
        <tr>
          <td style='padding-left:20px; height:30px;'>· 파일5</td>
          <td><input class="box" type="file" name='bf_file[]' /><?php
            if($file[4][href])
              echo "<input type='checkbox' name='bf_file_del[4]' value='1'><a href='{$file[4][href]}'>{$file[4][source]}({$file[4][size]})</a> 파일 삭제";
            if ($is_file_content)
              echo "<br /><input type='text' class=ed size=50 name='bf_content[4]' value='".addslashes(get_text($file[4][bf_content]))."' title='업로드 이미지 파일에 해당 되는 내용을 입력하세요.' />";
          ?></td>
        </tr>
        <?php } ?>
        <?php if ((int)$board[bo_upload_count] >= 6 || (int)$board[bo_upload_count] == 0) { ?>
        <tr>
          <td style='padding-left:20px; height:30px;'>· 파일6</td>
          <td><input class="box" type="file" name='bf_file[]' /><?php
            if($file[5][href])
              echo "<input type='checkbox' name='bf_file_del[5]' value='1'><a href='{$file[5][href]}'>{$file[5][source]}({$file[5][size]})</a> 파일 삭제";
            if ($is_file_content)
              echo "<br /><input type='text' class=ed size=50 name='bf_content[5]' value='".addslashes(get_text($file[5][bf_content]))."' title='업로드 이미지 파일에 해당 되는 내용을 입력하세요.' />";
          ?></td>
        </tr>
        <?php } ?>
        <?php if ((int)$board[bo_upload_count] >= 7 || (int)$board[bo_upload_count] == 0) { ?>
        <tr>
          <td style='padding-left:20px; height:30px;'>· 파일7</td>
          <td><input class="box" type="file" name='bf_file[]' /><?php
            if($file[6][href])
              echo "<input type='checkbox' name='bf_file_del[6]' value='1'><a href='{$file[6][href]}'>{$file[6][source]}({$file[6][size]})</a> 파일 삭제";
            if ($is_file_content)
              echo "<br /><input type='text' class=ed size=50 name='bf_content[6]' value='".addslashes(get_text($file[6][bf_content]))."' title='업로드 이미지 파일에 해당 되는 내용을 입력하세요.' />";
          ?></td>
        </tr>
        <?php } ?>
        <?php if ((int)$board[bo_upload_count] >= 8 || (int)$board[bo_upload_count] == 0) { ?>
        <tr>
          <td style='padding-left:20px; height:30px;'>· 파일8</td>
          <td><input class="box" type="file" name='bf_file[]' /><?php
            if($file[7][href])
              echo "<input type='checkbox' name='bf_file_del[7]' value='1'><a href='{$file[7][href]}'>{$file[7][source]}({$file[7][size]})</a> 파일 삭제";
            if ($is_file_content)
              echo "<br /><input type='text' class=ed size=50 name='bf_content[7]' value='".addslashes(get_text($file[7][bf_content]))."' title='업로드 이미지 파일에 해당 되는 내용을 입력하세요.' />";
          ?></td>
        </tr>
        <?php } ?>
        <?php if ((int)$board[bo_upload_count] >= 9 || (int)$board[bo_upload_count] == 0) { ?>
        <tr>
          <td style='padding-left:20px; height:30px;'>· 파일9</td>
          <td><input class="box" type="file" name='bf_file[]' /><?php
            if($file[8][href])
              echo "<input type='checkbox' name='bf_file_del[8]' value='1'><a href='{$file[8][href]}'>{$file[8][source]}({$file[8][size]})</a> 파일 삭제";
            if ($is_file_content)
              echo "<br /><input type='text' class=ed size=50 name='bf_content[8]' value='".addslashes(get_text($file[8][bf_content]))."' title='업로드 이미지 파일에 해당 되는 내용을 입력하세요.' />";
          ?></td>
        </tr>
        <?php } ?>
        <?php if ((int)$board[bo_upload_count] >= 10 || (int)$board[bo_upload_count] == 0) { ?>
        <tr>
          <td style='padding-left:20px; height:30px;'>· 파일10</td>
          <td><input class="box" type="file" name='bf_file[]' /><?php
            if($file[9][href])
              echo "<input type='checkbox' name='bf_file_del[9]' value='1'><a href='{$file[9][href]}'>{$file[9][source]}({$file[9][size]})</a> 파일 삭제";
            if ($is_file_content)
              echo "<br /><input type='text' class=ed size=50 name='bf_content[9]' value='".addslashes(get_text($file[9][bf_content]))."' title='업로드 이미지 파일에 해당 되는 내용을 입력하세요.' />";
          ?></td>
        </tr>
        <?php } ?>
        <?php } // 첨부파일 있을때?>



좋아요(추천)은 팁과 스킨을 만드는 힘의 원동력입니다. 적극 표현하세요 ^^
추천
3

댓글 5개

<? if ($is_file) { ?>
<? for ($filecount=0; $filecount<=10; $filecount++) { ?>
<?php if ((int)$board[bo_upload_count] >= ($filecount + 1) || (int)$board[bo_upload_count] == 0) { ?>
<tr>
  <td style='padding-left:20px; height:30px;'>· 파일3</td>
  <td><input class="box" type="file" name='bf_file[]' /><?php
    if($file[$filecount][href])
      echo "<input type='checkbox' name='bf_file_del[$filecount]' value='1'><a href='{$file[$filecount][href]}'>{$file[$filecount][source]}({$file[$filecount][size]})</a> 파일 삭제";
    if ($is_file_content)
      echo "<br /><input type='text' class=ed size=50 name='bf_content[$filecount]' value='".addslashes(get_text($file[$filecount][bf_content]))."' title='업로드 이미지 파일에 해당 되는 내용을 입력하세요.' />";
  ?></td>
</tr>
<?php } ?>
<?php } ?>
<?php } ?>

허락없이 조금 줄여 봤습니다..
전체 3,313 |RSS
그누4 팁자료실 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT