게시판 첨부파일 여러개 사용시 수정 에러

게시판 첨부파일 여러개 사용시 수정 에러

QA

게시판 첨부파일 여러개 사용시 수정 에러

본문

안녕하세요

현재 게시판에 첨부파일 업로드 받을 개수가 많고 위치도 따로따로 하고 싶어서

파일1번과 2번은 따로 뺐고

3번부터 12번까지 반복문 하나

13번부터 15번까지 반복문 하나 이렇게 배치를 했는데

따로 뺀 1번과 2번은 글쓰기 하고 수정하면 파일명 뜨면서 삭제 버튼이 정상적으로 생기는데

 

반복문 돌렸던 애들은 뜨질 않네요..

업로드는 정상적으로 됩니다!

 

1번 파일 입니다.


<div class="bo_w_flie write_div">
        <div class="file_wr write_div">
            <label for="bf_file_1" class="lb_icon"><i class="fa fa-folder-open" aria-hidden="true"></i><span class="sound_only"> 파일 #1</span></label>
            <input type="file" name="bf_file[]" id="bf_file_1" title="파일첨부 1 : 용량 <?php echo $upload_max_filesize ?> 이하만 업로드 가능" class="frm_file ">
        </div>
        <?php if ($is_file_content) { ?>
        <input type="text" name="bf_content[]" value="<?php echo ($w == 'u') ? $file[0]['bf_content'] : ''; ?>" title="파일 설명을 입력해주세요." class="full_input frm_input" size="50" placeholder="파일 설명을 입력해주세요.">
        <?php } ?>
 
        <?php if($w == 'u' && $file[0]['file']) { ?>
        <span class="file_del">
            <input type="checkbox" id="bf_file_del0" name="bf_file_del[0]" value="1"> <label for="bf_file_del0"><?php echo $file[0]['source'].'('.$file[0]['size'].')';  ?> 파일 삭제</label>
        </span>
        <?php } ?>
       
    </div>

 

2번 파일 입니다.


 <div class="bo_w_flie write_div">
        <div class="file_wr write_div">
            <label for="bf_file_2" class="lb_icon"><i class="fa fa-folder-open" aria-hidden="true"></i><span class="sound_only"> 파일 #2</span></label>
            <input type="file" name="bf_file[]" id="bf_file_2" title="파일첨부 2 : 용량 <?php echo $upload_max_filesize ?> 이하만 업로드 가능" class="frm_file ">
        </div>
        <?php if ($is_file_content) { ?>
        <input type="text" name="bf_content[]" value="<?php echo ($w == 'u') ? $file[1]['bf_content'] : ''; ?>" title="파일 설명을 입력해주세요." class="full_input frm_input" size="50" placeholder="파일 설명을 입력해주세요.">
        <?php } ?>
 
        <?php if($w == 'u' && $file[1]['file']) { ?>
        <span class="file_del">
            <input type="checkbox" id="bf_file_del1" name="bf_file_del[1]" value="1"> <label for="bf_file_del1"><?php echo $file[1]['source'].'('.$file[1]['size'].')';  ?> 파일 삭제</label>
        </span>
        <?php } ?>
       
    </div>

 

기존 반복문들 입니다.


<?php for ($i=2; $is_file && $i<12; $i++) { ?>
    <div class="bo_w_flie write_div">
        <div class="file_wr write_div">
            <label for="bf_file_<?php echo $i+1 ?>" class="lb_icon"><i class="fa fa-folder-open" aria-hidden="true"></i><span class="sound_only"> 파일 #<?php echo $i+1 ?></span></label>
            <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 ">
        </div>
        <?php if ($is_file_content) { ?>
        <input type="text" name="bf_content[]" value="<?php echo ($w == 'u') ? $file[$i]['bf_content'] : ''; ?>" title="파일 설명을 입력해주세요." class="full_input frm_input" size="50" placeholder="파일 설명을 입력해주세요.">
        <?php } ?>
 
        <?php if($w == 'u' && $file[$i]['file']) { ?>
        <span class="file_del">
            <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>
        </span>
        <?php } ?>
       
    </div>
    <?php }
    ?>
 
<?php
    for ($i=12; $is_file && $i<15; $i++) { ?>
    <div class="bo_w_flie write_div">
        <div class="file_wr write_div">
            <label for="bf_file_<?php echo $i ?>" class="lb_icon"><i class="fa fa-folder-open" aria-hidden="true"></i><span class="sound_only"> 파일 #<?php echo $i+1 ?></span></label>
            <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 ">
        </div>
        <?php if ($is_file_content) { ?>
        <input type="text" name="bf_content[]" value="<?php echo ($w == 'u') ? $file[$i]['bf_content'] : ''; ?>" title="파일 설명을 입력해주세요." class="full_input frm_input" size="50" placeholder="파일 설명을 입력해주세요.">
        <?php } ?>
 
        <?php if($w == 'u' && $file[$i]['file']) { ?>
        <span class="file_del">
            <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>
        </span>
        <?php } ?>
       
    </div>
   
    <?php } ?>

 

print_r로 찍어보고 db 보면서 잘 들어가는지 확인 하는데..

잘 들어가고 view페이지에서도 잘 나오는데 이상하게 수정시에만 안뜨네요

반복문이 2개인 이유는 쓰는 위치가 달라서 그렇습니다!

3번부터 12번은 다 파일이 들어갈때도 있고 부분만 들어갈수도 있습니다~

 

답변 부탁드립니다ㅠ

 

이 질문에 댓글 쓰기 :

답변 1

안나온다는 것은 값이 없다는 말이잖아요

상단에서 print_r($file); 해보면 금방 알수 있을테죠

했지만 이미지도 잘 표시되고 db 테이블에도 잘 입력됩니다..

        <?php if($w == 'u' && $file[$i]['file']) { ?>
        <span class="file_del">
            <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>
        </span>
        <?php } ?>

이부분이 $i 값이 잘 안물려져서 그런걸까요?

상단에서 잘나온다면
$i 값은 for문에서 정확하게 기술 되고 있으니 문제가 아니고
for ($i=2; $is_file && $i<12; $i++) <--여기서 $is_file 값이 문제겠네요
for문 다음에 echo $i; 해서 loop가 잘 돌아가는지 확인하면 되겠군요

위의 1번 2번은 $is_file 조건이 없으니 잘 나온 것이겠구요
for $i=0<--이렇게 하면 1번 2번도 안나올 것 같군요

$is_file은 업로드 권한이 없는 아이디는 나오지 않게 하는 겁니다

알려주신대로 $i를 찍어봤는데
loop가 잘 되고 있습니다..
찍힌 $i와 bf_no도 일치하구요 그렇지만
 <?php if($w == 'u' && $file[$i]['file']) { ?>
        <span class="file_del">
            <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>
        </span>
        <?php } ?>
이부분은 아직 먹통입니다ㅠㅠ
권한도 업로드 권한1입니다

답변을 작성하시기 전에 로그인 해주세요.
전체 7
QA 내용 검색

회원로그인

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