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

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

Winter0 3년 전 조회 1,867

안녕하세요.

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

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

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

답변 4개

채택된 답변
+20 포인트
3년 전

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

https://sir.kr/g5_tip/12466

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

답변에 대한 댓글 1개

W
Winter0
3년 전
해보니 잘됩니다. 감사합니다!

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

들레아빠

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

답변에 대한 댓글 1개

W
Winter0
3년 전
빠른 피드백 감사합니다! 해보려는 중입니다 ^^

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

들레아빠

</p>

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

<p>

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

답변에 대한 댓글 2개

W
Winter0
3년 전
이상하게 그대로 갖다붙이니 안되네요; 그래도 감사합니다
들레아빠
3년 전
참고만 하셔요.
[code]
<?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 } ?>
[/code]

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

w
3년 전

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

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

답변에 대한 댓글 1개

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

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

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

로그인