위토즈 - 개발자프로그램판매공간

정보공유

[PHP] 첨부파일 멀티 등록

 

 

<input type="hidden" name="del_cph_ix" id="del_cph_ix" value="" />

<table cellspacing="0" border="1" class="wz_tbl_1" id="wrap-tbl-photos">

    <caption></caption>

    <colgroup>

        <col width="auto"/>

        <col width="80px"/>

        <col width="80px"/>

    </colgroup>

    <thead>

    <tr>

        <th scope="row">첨부파일</th>

        <th scope="row">순서</th>

        <th scope="row"><a href="#none" class="btn_frmline add-tr">추가</a></th>

    </tr>

    </thead>

    <tbody>

    <?php

    if ($cnt_photos > 0) { 

        for ($z = 0; $z < $cnt_photos; $z++) { 

        ?>

        <tr>

            <td>

                <?php

                $sub_file_path = G5_DATA_PATH.'/wzb_plist/sub/'.$arr_photos[$z]['cph_file_name'];

                if (file_exists($sub_file_path) && $arr_photos[$z]['cph_file_name']) {

                    echo '<a href="'.G5_DATA_URL.'/wzb_plist/sub/'.$arr_photos[$z]['cph_file_name'].'" target="_blank" title="원본보기"><img src="'.G5_DATA_URL.'/wzb_plist/sub/'.$arr_photos[$z]['cph_file_name'].'" height="25"></a>';

                }

                ?>

                <input type="hidden" name="cph_ix[]"  value="<?php echo $arr_photos[$z]['cph_ix'];?>">

                <input type="file" name="cph_file[]" value="" class="frm_input" />

            </td>

            <td>

                <input type="text" name="cph_file_sort[]" value="<?php echo $arr_photos[$z]['cph_file_sort'];?>" class="frm_input full_input"  maxlength="10" />

            </td>

            <td class="td_mbstat"><a href="#none" class="btn_frmline del-tr" data-file-ix="<?php echo $arr_photos[$z]['cph_ix'];?>">삭제</a></td>

        </tr>

        <?php

        }

    }

    else {

        ?>

        <tr class="empty">

            <td colspan="3">추가버튼을 클릭해서 부가이미지를 등록해주세요.</td>

        </tr>

        <?php

    }

    ?>

    </tbody>

</table>

 

 

 

 

<script type="text/javascript">

<!--

    jQuery(document).ready(function () {

        $(document).on('click', '.add-tr', function() {

            $('.empty').remove();

            tbl_tr_add();

        });

        $(document).on('click', '.del-tr', function() {

            var cph_ix = $(this).attr('data-file-ix');

            var cph_ix_input = $('#del_cph_ix');

            if (cph_ix) {

                cph_ix_input.val((cph_ix_input.val() ? cph_ix_input.val() + ',' : '') + cph_ix);

            }

            

            $(this).closest('tr').remove();

            var tr_cnt = $('#wrap-tbl-photos tbody tr').length;

            if (tr_cnt == 0) {

                $('#wrap-tbl-photos').append('<tr class="empty"><td colspan="4">추가버튼을 클릭해서 부가이미지를 등록해주세요.</td></tr>');

            }

        });

    });

 

    function tbl_tr_add() {

        

        var tbl_tr_html = '';

            tbl_tr_html += '<tr>';

            tbl_tr_html += '    <td>';

            tbl_tr_html += '    <input type="hidden" name="cph_ix[]"  value="">';

            tbl_tr_html += '    <input type="file" name="cph_file[]" value="" class="frm_input" />';

            tbl_tr_html += '    </td>';

            tbl_tr_html += '    <td>';

            tbl_tr_html += '        <input type="text" name="cph_file_sort[]" value="" class="frm_input full_input"  maxlength="10" />';

            tbl_tr_html += '    </td>';

            tbl_tr_html += '    <td class="td_mbstat"><a href="#none" class="btn_frmline del-tr">삭제</a></td>';

            tbl_tr_html += '</tr>';

 

        $('#wrap-tbl-photos').append(tbl_tr_html);

    }

//-->

</script>

 

 

 

--------------------------------------------------------------

 

submit_ok.php

 

 

 

if ($w == 'd') { 

 

    // 관련 부가이미지 파일 삭제.

    $query = "select * from {테이블명} where cp_ix = '$cp_ix' ";

    $res = sql_query($query);

    while($row = sql_fetch_array($res)) { 

        @unlink(G5_DATA_PATH."/wzb_plist/sub/".$row['cph_file_name']);

    }

    if ($res) sql_free_result($res);

 

    // 삭제    

    $query = "delete from {테이블명} where cp_ix = '{$cp_ix}' ";

    sql_query($query);

 

    $query = "delete from {$g5['wzb_corp_table']} where cp_ix = '{$cp_ix}' ";

    sql_query($query);

 

    goto_url('./wzb_corp_list.php?'.$qstr);

 

 

if ($w == '' || $w == 'u') {

 

    // 부가이미지 정보변경

    $cph_ix = $_POST['cph_ix'];

    if (is_array($cph_ix)) { 

        $cnt_cph_ix = count($cph_ix);

        for ($i=0;$i<$cnt_cph_ix;$i++) { 

            $sql = "update {테이블명} set cph_file_sort = '".$_POST['cph_file_sort'][$i]."' where cph_ix = '".$cph_ix[$i]."' and cp_ix = '$cp_ix' ";

            sql_query($sql);

        } 

    } 

 

    // 부가이미지등록.

    @mkdir(G5_DATA_PATH.'/wzb_plist/sub/', G5_DIR_PERMISSION);

    @chmod(G5_DATA_PATH.'/wzb_plist/sub/', G5_DIR_PERMISSION);

    $sqlCommon = "";

    $file = wz_file_upload(G5_DATA_PATH."/wzb_plist/sub/", (1048576 * 5), "cph_file", "jpg|gif|tiff|png|jpeg|bmp", "edit");

    $cph_file_name = "";

    if (is_array($file)) {

        for ($i=0;$i<count($file);$i++) { 

            $cph_file_name = $file[$i]["filename"];

            $cph_file_name_org = $file[$i]["filename_org"];

            $cph_file_size = $file[$i]["filesize"];

            $cph_file_sort = $file[$i]["filesort"];

            if ($cph_file_name) { 

                $sql = " insert into {테이블명} set 

                                cp_ix = '$cp_ix',

                                cph_file_name = '$cph_file_name', 

                                cph_file_name_org = '$cph_file_name_org', 

                                cph_file_size = '$cph_file_size', 

                                cph_file_sort = '$cph_file_sort'

                                 ";

                sql_query($sql);

            }     

        }

    }

 

    $del_cph_ix = $_POST['del_cph_ix'];

    if ($del_cph_ix) { 

        $arr_cph_ix = array_map('trim', explode(',', $del_cph_ix));

        $cnt_cph_ix = count($arr_cph_ix);

        for ($i=0;$i<$cnt_cph_ix;$i++) { 

            $sql = " select cph_file_name from {테이블명} where cph_ix = '".$arr_cph_ix[$i]."' and cp_ix = '$cp_ix' ";

            $cph = sql_fetch($sql);

            @unlink(G5_DATA_PATH."/wzb_plist/sub/".$cph['cph_file_name']);

 

            $sql = "delete from {테이블명} where cph_ix = '".$arr_cph_ix[$i]."' and cp_ix = '$cp_ix' ";

            sql_query($sql);

        } 

    } 

}

 

 

정보공유
Total 74건 3 페이지
번호 제목 글쓴이 날짜 조회
44 d-day 계산, 디데이 계산 함수 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 04-06 35847
43 URL 주소입력받을때 반드시 http 붙게 처리해야할 경우 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 04-06 29199
42 한글 초성 추출하기 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 03-30 31752
열람중 첨부파일 멀티 등록 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 03-21 27202
40 방문자의 접속국가 처리. 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 02-23 45414
39 해외 CMS 솔루션 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 02-10 43671
38 함수, 클래스 사용가능여부 확인. 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 01-13 30200
37 Methods with the same name as their class will not be constructors in a future version of PHP 오류. 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 01-13 29828
36 2차 도메인 뽑아내기. 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 01-05 46014
35 외부에서 자동로그인 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 12-27 32818
34 php 현재 페이지 주소 알아내기 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 12-21 32533
33 [코드이그나이터] 한사이트에 여러도메인 사용하기 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 12-14 30887
32 로그 기록 남기기 샘플 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 12-06 30719
31 코드이그나이터 검색 기본 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 11-14 31156
30 네이밍, 코딩룰 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 10-24 45433