첨부파일 탭으로 나누기 질문입니다!

첨부파일 탭으로 나누기 질문입니다!

QA

첨부파일 탭으로 나누기 질문입니다!

답변 1

본문

197a8197a4ea28fccc67b3aaf66c6889_1497431950_8024.jpg
 

 

안녕하세요

 항상 질문 검색만하다가, 처음으로 글을 올려봅니다 ㅜ

 

 

지금 제가 구현하려고하는게

갤러리 게시글 상세페이지에 첨부파일들을 TAB1, 2, 3로 나누어서 노출 시키려고합니다.

 

우선 첨부파일 3장은 고정으로 

1,2번째는 갤러리 게시판 목록에서 마우스 on/off 사진으로사용하고요

3번째는 상세페이지의 프로필 사진으로 사용합니다.

 

4번째 부터는 TAB메뉴에 노출될 이미지들인데

각각의 TAB은 첨부파일 50개로 제한뒀구요

 

그래서 총 파일 업로드 개수는 153개입니다 (127개까지밖에안됐는데 정수형 범위를 수정했어요)

 

문제는 ㅠ

게시글 업로드 할때 예를 들어 

197a8197a4ea28fccc67b3aaf66c6889_1497432718_8934.JPG
Magazine 탭의 첨부파일을 하나더 추가해서

총 2개의 파일을 올리고 난 후 그 게시글을 수정할 때 또한 form이 위와 같았으면 하는데

 

197a8197a4ea28fccc67b3aaf66c6889_1497432780_5226.JPG
현재는 수정 페이지에서 바로 위 캡쳐화면 처럼 나옵니다

 

수정할때에 for문을 어떻게 작성해야될까요?ㅠ

또 상세페이지(view페이지)에서는 어떻게 분기처리하여 tab메뉴를 나눠야할지도 막막합니다

 

제 질문의 요지가 이해가 가신다면 답변 부탁드립니다!ㅠㅠ

 

 

아래는 테스트 URL입니다.

http://daisydam.cafe24.com/g5/bbs/board.php?bo_table=gall&page= 

 

 

소스는 아래와 같습니다 ㅠㅠ

 

감사합니다

 

 

 

 

 

write.skin.php

<?php

if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가

 

// add_stylesheet('css 구문', 출력순서); 숫자가 작을 수록 먼저 출력됨

add_stylesheet('<link rel="stylesheet" href="'.$board_skin_url.'/style.css">', 0);

?>

 

<section id="bo_w">

    <h2 id="container_title"><?php echo $g5['title'] ?></h2>

 

    <!-- 게시물 작성/수정 시작 { -->

    <form name="fwrite" id="fwrite" action="<?php echo $action_url ?>" onsubmit="return fwrite_submit(this);" method="post" enctype="multipart/form-data" autocomplete="off" style="width:<?php echo $width; ?>">

    <input type="hidden" name="uid" value="<?php echo get_uniqid(); ?>">

    <input type="hidden" name="w" value="<?php echo $w ?>">

    <input type="hidden" name="bo_table" value="<?php echo $bo_table ?>">

    <input type="hidden" name="wr_id" value="<?php echo $wr_id ?>">

    <input type="hidden" name="sca" value="<?php echo $sca ?>">

    <input type="hidden" name="sfl" value="<?php echo $sfl ?>">

    <input type="hidden" name="stx" value="<?php echo $stx ?>">

    <input type="hidden" name="spt" value="<?php echo $spt ?>">

    <input type="hidden" name="sst" value="<?php echo $sst ?>">

    <input type="hidden" name="sod" value="<?php echo $sod ?>">

    <input type="hidden" name="page" value="<?php echo $page ?>">

    

    <?php

    $option = '';

    $option_hidden = '';

    if ($is_notice || $is_html || $is_secret || $is_mail) {

        $option = '';

        if ($is_notice) {

            $option .= "\n".'<input type="checkbox" id="notice" name="notice" value="1" '.$notice_checked.'>'."\n".'<label for="notice">공지</label>';

        }

 

        if ($is_html) {

            if ($is_dhtml_editor) {

                $option_hidden .= '<input type="hidden" value="html1" name="html">';

            } else {

                $option .= "\n".'<input type="checkbox" id="html" name="html" onclick="html_auto_br(this);" value="'.$html_value.'" '.$html_checked.'>'."\n".'<label for="html">html</label>';

            }

        }

 

        if ($is_secret) {

            if ($is_admin || $is_secret==1) {

                $option .= "\n".'<input type="checkbox" id="secret" name="secret" value="secret" '.$secret_checked.'>'."\n".'<label for="secret">비밀글</label>';

            } else {

                $option_hidden .= '<input type="hidden" name="secret" value="secret">';

            }

        }

 

        if ($is_mail) {

            $option .= "\n".'<input type="checkbox" id="mail" name="mail" value="mail" '.$recv_email_checked.'>'."\n".'<label for="mail">답변메일받기</label>';

        }

    }

 

    echo $option_hidden;

    ?>

 

    <div class="tbl_frm01 tbl_wrap">

        <table>

        <tbody>

        <?php if ($is_name) { ?>

        <tr>

            <th scope="row"><label for="wr_name">이름<strong class="sound_only"> 필수</strong></label></th>

            <td><input type="text" name="wr_name" value="<?php echo $name ?>" id="wr_name" required class="frm_input required" size="10" maxlength="20"></td>

        </tr>

        <?php } ?>

 

        <?php if ($is_password) { ?>

        <tr>

            <th scope="row"><label for="wr_password">비밀번호<strong class="sound_only"> 필수</strong></label></th>

            <td><input type="password" name="wr_password" id="wr_password" <?php echo $password_required ?> class="frm_input <?php echo $password_required ?>" maxlength="20"></td>

        </tr>

        <?php } ?>

        <tr>

            <th scope="row"><label for="wr_subject">이름(한글)<strong class="sound_only">필수</strong></label></th>

            <td>

                <div id="autosave_wrapper">

                    <input type="text" name="wr_subject" value="<?php echo $subject ?>" id="wr_subject" required class="frm_input required" size="10" maxlength="20">

                    <?php if ($is_member) { // 임시 저장된 글 기능 ?>

                    <script src="<?php echo G5_JS_URL; ?>/autosave.js"></script>

                    <?php if($editor_content_js) echo $editor_content_js; ?>

                    <!--

                    <button type="button" id="btn_autosave" class="btn_frmline">임시 저장된 글 (<span id="autosave_count"><?php echo $autosave_count; ?></span>)</button>

                    <div id="autosave_pop">

                        <strong>임시 저장된 글 목록</strong>

                        <div><button type="button" class="autosave_close"><img src="<?php echo $board_skin_url; ?>/img/btn_close.gif" alt="닫기"></button></div>

                        <ul></ul>

                        <div><button type="button" class="autosave_close"><img src="<?php echo $board_skin_url; ?>/img/btn_close.gif" alt="닫기"></button></div>

                    </div>

                    -->

                    <?php } ?>

                </div>

            </td>

        </tr>

        <tr>

            <th scope="row"><label for="wr_1">이름(영문)<strong class="sound_only"> 필수</strong></label></th>

            <td><input type="text" name="wr_1" value="<?php echo $wr_1 ?>" class="frm_input" size="10" maxlength="20"></td>

        </tr>

        

        <tr>

            <th scope="row"><label for="wr_2">Height<strong class="sound_only"> 필수</strong></label></th>

            <td><input type="text" name="wr_2" value="<?php echo $wr_2 ?>" class="frm_input" size="10" maxlength="3"></td>

        </tr>

        <tr>

            <th scope="row"><label for="wr_3">Bust<strong class="sound_only"> 필수</strong></label></th>

            <td><input type="text" name="wr_3" value="<?php echo $wr_3 ?>" class="frm_input" size="10" maxlength="2"></td>

        </tr>

        <tr>

            <th scope="row"><label for="wr_4">Waist<strong class="sound_only"> 필수</strong></label></th>

            <td><input type="text" name="wr_4" value="<?php echo $wr_4 ?>" class="frm_input" size="10" maxlength="2"></td>

        </tr>

        <tr>

            <th scope="row"><label for="wr_5">Hip<strong class="sound_only"> 필수</strong></label></th>

            <td><input type="text" name="wr_5" value="<?php echo $wr_5 ?>" class="frm_input" size="10" maxlength="2"></td>

        </tr>

        <tr>

            <th scope="row"><label for="wr_6">Shoe<strong class="sound_only"> 필수</strong></label></th>

            <td><input type="text" name="wr_6" value="<?php echo $wr_6 ?>" class="frm_input" size="10" maxlength="3"></td>

        </tr>

 

        <tr style="display:none;">

            <th scope="row"><label for="wr_content">내용<strong class="sound_only">필수</strong></label></th>

            <td class="wr_content">

                <?php if($write_min || $write_max) { ?>

                <!-- 최소/최대 글자 수 사용 시 -->

                <p id="char_count_desc">이 게시판은 최소 <strong><?php echo $write_min; ?></strong>글자 이상, 최대 <strong><?php echo $write_max; ?></strong>글자 이하까지 글을 쓰실 수 있습니다.</p>

                <?php } ?>

                <?php echo $editor_html; // 에디터 사용시는 에디터로, 아니면 textarea 로 노출 ?>

                <?php if($write_min || $write_max) { ?>

                <!-- 최소/최대 글자 수 사용 시 -->

                <div id="char_count_wrap"><span id="char_count"></span>글자</div>

                <?php } ?>

            </td>

        </tr>

        

        <tr>

            <th scope="row"><label for="wr_7">MAGAZINE<strong class="sound_only"> 필수</strong></label></th>

            <td>

            <textarea name="wr_7" value="<?php echo $wr_7 ?>" id="" class="frm_input"></textarea>

            </td>

        </tr>

        <tr>

            <th scope="row"><label for="wr_8">SHOW<strong class="sound_only"> 필수</strong></label></th>

            <td>

            <textarea name="wr_8" value="<?php echo $wr_8 ?>" id="" class="frm_input"></textarea>

            </td>

        </tr>

        <tr>

            <th scope="row"><label for="wr_9">AD<strong class="sound_only"> 필수</strong></label></th>

            <td>

            <textarea name="wr_9" value="<?php echo $wr_9 ?>" id="" class="frm_input"></textarea>

            </td>

        </tr>

        <tr>

            <th scope="row"><label for="wr_10">CF<strong class="sound_only"> 필수</strong></label></th>

            <td>

            <textarea name="wr_10" value="<?php echo $wr_10 ?>" id="" class="frm_input"></textarea>

            </td>

        </tr>

        <tr>

            <th scope="row"><label for="wr_11">TV<strong class="sound_only"> 필수</strong></label></th>

            <td>

            <textarea name="wr_11" value="<?php echo $wr_11 ?>" id="" class="frm_input"></textarea>

            </td>

        </tr>

        <tr>

            <th scope="row"><label for="wr_12">MOVIE<strong class="sound_only"> 필수</strong></label></th>

            <td>

            <textarea name="wr_12" value="<?php echo $wr_12 ?>" id="" class="frm_input"></textarea>

            </td>

        </tr>

        <?php //for ($i=0; $is_file && $i<$file_count; $i++) { ?>

        <?php for ($i=0; $is_file && $i<3; $i++) { ?>

        <tr>

            <th scope="row">

<?

if($i == 0){

echo "리스트 썸네일 OFF";

}elseif($i == 1){

echo "리스트 썸네일 ON";

}elseif($i == 2){

echo "메인 프로필 사진";

}

?>

            </th>

            <td>

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

                <?php if($w == 'u' && $file[$i]['file']) { ?>

                <input type="checkbox" id="bf_file_del<?php echo $i ?>" name="bf_file_del[<?php echo $i;  ?>]" value="1"> <label for="bf_file_del<?php echo $i ?>"><?php echo $file[$i]['source'].'('.$file[$i]['size'].')';  ?> 파일 삭제</label>

                <?php } ?>

            </td>

        </tr>

        <?php } ?>

        <?php

        $startIndex = 3;

        if($w == 'u'){

if($file['count'] <= 6){

$a = $startIndex+3;

}

echo $file['count'];

        }else{

        $a = $startIndex+3;

        }

        for ($i=$startIndex; $is_file && $i<$a; $i++){

if($i == $startIndex){

$tabMenuTit = "Magazine 탭 - 파일 ".($i-($startIndex-1));

$rowTit = "magazineArea";

}elseif($i == $startIndex+1){

$tabMenuTit =  "Show 탭 - 파일 ".($i-(($startIndex+1)-1));

$rowTit = "showArea";

}elseif($i == $startIndex+2){

$tabMenuTit =  "TV/CF 탭 - 파일 ".($i-(($startIndex+2)-1));

$rowTit = "tvArea";

}

         ?>

        <tr class="<?=$rowTit?>">

            <th scope="row" class="fileNo">

<?

echo $tabMenuTit;

?>

            </th>

            <td>

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

<?

if($i == $startIndex){

echo "<button type=\"button\" class=\"btn_frmline fwzadd btnMagazine\">추가</button>";

}elseif($i == $startIndex+1){

echo "<button type=\"button\" class=\"btn_frmline fwzadd btnShow\">추가</button>";

}elseif($i == $startIndex+2){

echo "<button type=\"button\" class=\"btn_frmline fwzadd btnTv\">추가</button>";

}

?>

<?php if($w == 'u' && $file[$i]['file']) { ?>

<input type="checkbox" id="bf_file_del<?php echo $i ?>" name="bf_file_del[<?php echo $i;  ?>]" value="1"> <label for="bf_file_del<?php echo $i ?>"><?php echo $file[$i]['source'].'('.$file[$i]['size'].')';  ?> 파일 삭제</label>

<?php } ?>

            </td>

        </tr>

        <?php } ?>

        <!--

        <?php

        $startIndex2 = 52;

        if($w == 'u'){

        $a2 = $file['count']; 

        }else{

        $a2 = $startIndex2+1;

        }

        for ($i=$startIndex2; $is_file && $i<$a2; $i++) {

         ?>

        <tr class="showArea">

            <th scope="row" class="fileNo">

<?

echo "Show 탭 - 파일 ".($i-($startIndex2-1));

?>

            </th>

            <td>

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

<?php if ($i==$startIndex2) { ?>

<button type="button" class="btn_frmline fwzadd">추가</button>

<?php } ?>

<?php if($w == 'u' && $file[$i]['file']) { ?>

<input type="checkbox" id="bf_file_del<?php echo $i ?>" name="bf_file_del[<?php echo $i;  ?>]" value="1"> <label for="bf_file_del<?php echo $i ?>"><?php echo $file[$i]['source'].'('.$file[$i]['size'].')';  ?> 파일 삭제</label>

<?php } ?>

            </td>

        </tr>

        <?php } ?>

        -->

        <!--

        <?php

        for ($i=0; $is_file && $i<=$file['count'];$i++){

?>

<tr>

<th scope="row" class="fileNo">

<?

echo "파일 ".($i+1);

?>

</th>

<td>

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

<?php if ($i==0) { ?>

<button type="button" class="btn_frmline fwzadd">추가</button>

<?php } ?>

<?php if($w == 'u' && $file[$i]['file']) { ?>

<input type="checkbox" id="bf_file_del<?php echo $i ?>" name="bf_file_del[<?php echo $i;  ?>]" value="1"> <label for="bf_file_del<?php echo $i ?>"><?php echo $file[$i]['source'].'('.$file[$i]['size'].')';  ?> 파일 삭제</label>

<?php } ?>

</td>

</tr>

<?php } ?>

-->

        <?php if ($is_guest) { //자동등록방지  ?>

        <tr>

            <th scope="row">자동등록방지</th>

            <td>

                <?php echo $captcha_html ?>

            </td>

        </tr>

        <?php } ?>

 

        </tbody>

        </table>

    </div>

 

    <div class="btn_confirm">

        <input type="submit" value="작성완료" id="btn_submit" accesskey="s" class="btn_submit">

        <a href="./board.php?bo_table=<?php echo $bo_table ?>" class="btn_cancel">취소</a>

    </div>

    </form>

    <script>

    <?php if($write_min || $write_max) { ?>

    // 글자수 제한

    var char_min = parseInt(<?php echo $write_min; ?>); // 최소

    var char_max = parseInt(<?php echo $write_max; ?>); // 최대

    check_byte("wr_content", "char_count");

 

    $(function() {

        $("#wr_content").on("keyup", function() {

            check_byte("wr_content", "char_count");

        });

    });

 

    <?php } ?>

    fwrite.wr_content.value = "내용없음";

    function html_auto_br(obj)

    {

        if (obj.checked) {

            result = confirm("자동 줄바꿈을 하시겠습니까?\n\n자동 줄바꿈은 게시물 내용중 줄바뀐 곳을<br>태그로 변환하는 기능입니다.");

            if (result)

                obj.value = "html2";

            else

                obj.value = "html1";

        }

        else

            obj.value = "";

    }

 

    function fwrite_submit(f)

    {

        <?php echo $editor_js; // 에디터 사용시 자바스크립트에서 내용을 폼필드로 넣어주며 내용이 입력되었는지 검사함   ?>

 

        var subject = "";

        var content = "";

        $.ajax({

            url: g5_bbs_url+"/ajax.filter.php",

            type: "POST",

            data: {

                "subject": f.wr_subject.value,

                "content": f.wr_content.value

            },

            dataType: "json",

            async: false,

            cache: false,

            success: function(data, textStatus) {

                subject = data.subject;

                content = data.content;

            }

        });

 

        if (subject) {

            alert("제목에 금지단어('"+subject+"')가 포함되어있습니다");

            f.wr_subject.focus();

            return false;

        }

 

        if (content) {

            alert("내용에 금지단어('"+content+"')가 포함되어있습니다");

            if (typeof(ed_wr_content) != "undefined")

                ed_wr_content.returnFalse();

            else

                f.wr_content.focus();

            return false;

        }

 

        if (document.getElementById("char_count")) {

            if (char_min > 0 || char_max > 0) {

                var cnt = parseInt(check_byte("wr_content", "char_count"));

                if (char_min > 0 && char_min > cnt) {

                    alert("내용은 "+char_min+"글자 이상 쓰셔야 합니다.");

                    return false;

                }

                else if (char_max > 0 && char_max < cnt) {

                    alert("내용은 "+char_max+"글자 이하로 쓰셔야 합니다.");

                    return false;

                }

            }

        }

 

        <?php echo $captcha_js; // 캡챠 사용시 자바스크립트에서 입력된 캡챠를 검사함  ?>

 

        document.getElementById("btn_submit").disabled = "disabled";

 

        return true;

    }

    

<?php if ($is_file) {?>

function addFileInput(startIdx, appendArea){

var fileLimitLeng = 50;

startIdx = parseInt(startIdx); 

var flen = $("input[name='bf_file[]']").length;

var flen2 = $(".tbl_frm01 table:first-child").find('.'+appendArea+' input[name="bf_file[]"]').length;

//var tabMenuTit = appendArea.replace('Area', '');

//tabMenuTit = tabMenuTit.substring(0, 1).toUpperCase() + tabMenuTit.substring(1, tabMenuTit.length);

var tabMenuTit = '';

if(appendArea == 'magazineArea'){

tabMenuTit = 'Magazine';

}else if(appendArea == 'showArea'){

tabMenuTit = 'Show';

}else if(appendArea == 'tvArea'){

tabMenuTit = 'TV/CF';

}

//var upload_count = 53;

//var addedFlen = flen-2;

var upload_count = fileLimitLeng;

if (upload_count && flen2 >= upload_count)

{

alert("탭의 첨부파일은 각 "+upload_count+"개 까지만 파일 업로드가 가능합니다.");

return;

}

var appendHtml = "";

appendHtml += "<tr class='"+appendArea+"'>";

appendHtml += "<th scope='row' class='fileNo'>"+tabMenuTit+" 탭 - 파일 "+(flen2+1)+"</th>";

appendHtml += "<td>";

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

appendHtml += " <button type='button' class='btn_frmline fwzdel'>삭제</button>";

appendHtml += "</td>";

appendHtml += "</tr>";

 

//$(".tbl_frm01 table:first-child").append(appendHtml);

$(".tbl_frm01 table:first-child").find('.'+appendArea).eq(flen2-1).after(appendHtml);

}

 

$(document).ready(function(){

// 첨부파일 추가.

$('.tbl_frm01 table .fwzadd').live('click',(function(){

if($(this).hasClass('btnMagazine')){

addFileInput("<?=$startIndex?>", 'magazineArea');

}else if($(this).hasClass('btnShow')){

addFileInput("<?=$startIndex?>", 'showArea');

}else if($(this).hasClass('btnTv')){

addFileInput("<?=$startIndex?>", 'tvArea');

}

var flen = $("input[name='bf_file[]']").length;

//$('input[name="wr_13"]').val(flen);

//alert(flen);

}));

 

// 첨부파일 삭제.

$('.tbl_frm01 table .fwzdel').live('click',(function(){

$(this).parents("tr:first").remove(); 

if($(this).parents('tr').hasClass('magazineArea')){

$('.magazineArea .fileNo').each(function(i){

$(this).text('Magazine 탭 - 파일 '+(i+1));

});

}else if($(this).parents('tr').hasClass('showArea')){

$('.showArea .fileNo').each(function(i){

$(this).text('Show 탭 - 파일 '+(i+1));

});

}else if($(this).parents('tr').hasClass('tvArea')){

$('.tvArea .fileNo').each(function(i){

$(this).text('TV/CF 탭 - 파일 '+(i+1));

});

}

var flen = $("input[name='bf_file[]']").length;

//$('input[name="wr_13"]').val(flen);

//alert(flen);

/*

var flen = $('.fileNo').length;

$(this).parents("tr:first").remove(); 

$('.fileNo').each(function(i){

$(this).text('파일 '+(i+1));

});

*/

}));

 

});

<?php } ?>

    </script>

</section>

<!-- } 게시물 작성/수정 끝 -->

 

 

 

이 질문에 댓글 쓰기 :

답변 1

그냥 배열 을 만들어서 하는 것으로 해야 

 

그런데 구지 저러게 할필요가있나요?

 

저러게 한다면 페이지의 로딩 속도와 DB 검색 부분에서 많은 문제점이 발생할꺼라고보는데,,

또한 어떤 서버를 쓰시는 지모르게지만 

서버회사에서 수정 페이지나 입력 페이지에 서 

카운트 제한이 걸려서 안될껀데 

단독을 쓴다면,,야, 상관없게지만...

지금 영카트 상품 등록페이지도 옵션 조금만 많아지면 카운트 제안이 걸리느데,,

또 어떤 이미지나 어떤 파일 인지 모르게지만 한번 에 업로드하는 용량 제안 을 안하신다면 흠,,

 

주제넘는 걱정 이라면죄성합니다

 

 

 

답변을 작성하시기 전에 로그인 해주세요.
QA 내용 검색
질문등록
전체 17,962
© SIRSOFT
현재 페이지 제일 처음으로