첨부파일 이미지 바로 확인할 수 있게 하는 방법?

첨부파일 이미지 바로 확인할 수 있게 하는 방법?

QA

첨부파일 이미지 바로 확인할 수 있게 하는 방법?

본문

안녕하세요.

처음 글 쓸 때, 첨부파일을 넣으면 텍스트로만 표시되잖아요?

첨부파일로 넣은 이미지를 바로 확인할 수 있게 하려면 어떻게 해야 할까요?

이 질문에 댓글 쓰기 :

답변 4

input type="file" 에서 이미지 첨부시 바로 보여주기

https://sir.kr/g5_tip/12466

file업로드시 이미지 미리 썸네일로 보여주기 (tistory.com) 이거 참고하시면 되겠네요.

아 이답변을 이제서야 봤네요....!!!!! ㅜㅜㅜㅜ 제가 최근에 시야가 많이 좁아져서요... 답변 감사드립니다
+근데 실제로 해보니 작동되진 않네요. 오래전 글이라 그런가봅니다


            <label style="margin-left:40px;cursor:pointer" title="<?php if($file[$i]['file']){echo $file[$i]['path']."/".$file[$i]['file'].' 클릭 복사';}?>">
            <?php
            $file = get_file($bo_table, $wr_id);
            $image = urlencode($file[$i]['file']);
            $image_path = G5_DATA_PATH.'/file/'.$bo_table;
            $image_url = G5_DATA_URL.'/file/'.$bo_table;
            if (preg_match("/\.(gif|jpg|jpeg|png|webp)$/i", $image)) {
            $thumb = thumbnail($image, $image_path , $image_path , 38, 28, false, true);
            $image_content = $image_url.'/'.$thumb;
              } else {
              $pattern = "#.+\.(?P<ftype>[a-z]{3})#i";
              preg_match($pattern, $file[$i]['source'], $match);
              if($match['ftype']){
                $image_content = $board_skin_url.'/img/'.$match['ftype'].'.gif';
                } else {
                $image_content = $board_skin_url.'/img/noimage.png';
                }
            }
            echo "<img class='img_preview".($i+1)."' style='width:38px;height:28px;opacity:.8' src='".$image_content."'>";
            ?></label><?php echo "</span>";?>

참고만 하셔요.


    <?php for ($i=0; $is_file && $i<$file_count; $i++) { ?>
    <div class="bo_w_flie write_div">
        <div class="file_wr write_div" title="mp3/4,pdf/ppt/xls, mediaList_1 text-file upload">
            <label for="bf_file_<?php echo $i+1 ?>" class="lb_icon"><i id="fa_<?php echo $i+1 ?>" class="fa fa-folder-open" aria-hidden="true"></i><span class="sound_only"> 파일 #<?php echo $i+1 ?></span></label>
            <?php if ($file[$i]['file']) echo "<span style=cursor:pointer onclick=copyMode('".$file[$i]['path'].'/'.$file[$i]['file']."','파일주소가')>";?>
            <label style="margin-left:40px;cursor:pointer" title="<?php if($file[$i]['file']){echo $file[$i]['path']."/".$file[$i]['file'].' 클릭 복사';}?>">
            <?php
            $file = get_file($bo_table, $wr_id);
            $image = urlencode($file[$i]['file']);
            $image_path = G5_DATA_PATH.'/file/'.$bo_table;
            $image_url = G5_DATA_URL.'/file/'.$bo_table;
            if (preg_match("/\.(gif|jpg|jpeg|png|webp)$/i", $image)) {
            $thumb = thumbnail($image, $image_path , $image_path , 38, 28, false, true);
            $image_content = $image_url.'/'.$thumb;
              } else {
              $pattern = "#.+\.(?P<ftype>[a-z]{3})#i";
              preg_match($pattern, $file[$i]['source'], $match);
              if($match['ftype']){
                $image_content = $board_skin_url.'/img/'.$match['ftype'].'.gif';
                } else {
                $image_content = $board_skin_url.'/img/noimage.png';
                }
            }
            echo "<img class='img_preview".($i+1)."' style='width:38px;height:28px;opacity:.8' src='".$image_content."'>";
            ?></label><?php echo "</span>";?>
            <input type="radio" class="radio<?php echo $i+1 ?>" id="radio_<?php echo $i+1 ?>" name="wr_6" value="<?php echo $i ?>" <?php if ($write['wr_6'] == $i&&$write['wr_6'] >= '0') echo "checked";if(!preg_match("/\.(gif|jpg|jpeg|png|webp)$/i", $image))echo 'disabled';?> title="select list view"> <label for="<?php echo $i ?>" title="list file_<?php echo $i+1 ?>" class="homepage"></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 "-->
            <input type="button" value="file 찿기" id="ba_file_<?php echo $i+1 ?>" onclick="document.getElementById('bf_file_<?php echo $i+1 ?>').click()" title="Attachments <?php echo $i+1 ?> : Volume <?php echo $upload_max_filesize ?> Only the following can be uploaded" class="frm_file ">
            <label for="<?php echo $i ?>" id="file-name_<?php echo $i+1 ?>" class="homepage">선택된 file 없음</label>
            <input type="file" name="bf_file[]" style="display:none" id="bf_file_<?php echo $i+1 ?>" title="파일첨부 <?php echo $i+1 ?> : 용량 <?php echo $upload_max_filesize ?> 이하만 업로드 가능" class="frm_file ">
            <script>
            inputElement<?php echo $i+1 ?> = document.getElementById('bf_file_<?php echo $i+1 ?>');
            labelElement<?php echo $i+1 ?> = document.getElementById('file-name_<?php echo $i+1 ?>');
            inputElement<?php echo $i+1 ?>.onchange = function(event) {
            var path = inputElement<?php echo $i+1 ?>.value;
            labelElement<?php echo $i+1 ?>.innerHTML = path.split(/(\\|\/)/g).pop();
            }
            </script>
        </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 ?>"><a href="<?php echo $file[$i]['href']?>"><?php echo $file[$i]['source'].'('.$file[$i]['size'].')';?></a> 파일 삭제</label>
        </span>
        <?php } ?>
    </div>
    <?php } ?>

1954383429_1655850276.6895.png

답변을 작성하시기 전에 로그인 해주세요.
전체 0 | RSS
QA 내용 검색
  • 개별 목록 구성 제목 답변작성자조회작성일
  • 질문이 없습니다.

회원로그인

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