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

새로 만든 페이지에 이미지 파일 첨부 기능 질문 채택완료

하남시불빠따 4년 전 조회 3,400

write.skin.php에 있는 파일 첨부 부분을 이용해서 새 페이지에 해당 기능을 사용하려고 하는데

단순하게 파일 첨부 입력폼과 첨부파일(이미지)을 뿌려주는 코드만으로 안되더라구요

 

새 페이지에 적용해야되기 때문에 파일 관련 db를 사용해야되는데 엄청 복잡해지네요 ㅜㅜ

 

</p>

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

    <div class="bo_w_flie write_div_file">

        <div class="file_wr write_div_file">

            <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 imgext">

        </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 } ?></p>

<p>        <?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 } ?></p>

<p>

일단, write.skin.php에 있는 부분인데 이걸 따와서

 

</p>

<p>        <div class="bo_w_flie write_div" style="margin-bottom:50px;">

            <div class="file_wr write_div">

                <input type="file" name="bf_file[]" id="bf_file_1" title="파일첨부 1 : 용량 <?php echo $upload_max_filesize ?> 이하만 업로드 가능" class="frm_file imgext" style="float:right;">

            </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 } ?></p>

<p>            <?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></p>

<p>

요런식으로 바꿔줬습니다... 파일 첨부 입력폼은 잘뜨더라구요

 

db에 파일 정보를 저장해야되는데 도무지 어떻게 해야될지 모르겠습니다...

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

답변 1개

채택된 답변
+20 포인트
진서기
4년 전

php 파일 업로드하는 부분부터 보세요.

https://zetawiki.com/wiki/PHP_%ED%8C%8C%EC%9D%BC_%EC%97%85%EB%A1%9C%EB%93%9C_%EA%B5%AC%ED%98%84

 

업로드 완료 부분에 DB 삽입하면 됩니다.

 

 

로그인 후 평가할 수 있습니다

답변에 대한 댓글 1개

하남시불빠따
4년 전
g5_board_file 처럼 db를 만들어야될거 같은데 맞나요? 맞다면 새로 만들 g5_board_file 테이블의 필드값을 어떻게 해야될까요? 그리고 그 페이지의 update.php에서 데이터를 어떻게 저장해야될까요...
감을 못잡겠어서 ㅜㅜ

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

답변을 작성하려면 로그인이 필요합니다.

로그인