채택완료

에디터 이미지 암호화

2019-04-15 (월) 05:40:58 2,024

기존

Copy
<?php } else {
$thumb = get_list_thumbnail($board['bo_table'], $list[$i]['wr_id'], $board['bo_gallery_width'], $board['bo_gallery_height'], false, true);

          if($thumb['src']) {
            $img_content = '<img src="'.$thumb['src'].'" alt="'.$thumb['alt'].'" style="width:80px; height:50px;">';
           } else {
           $img_content = '<div class="no_image" style="margin-left:5px; width:80px; height:50px; line-height:50px; text-align:center; border:1px solid #00495f">no image</div>';
            }
    echo $img_content;
 }
 ?>
 
                            

이와같이 처리했는데 왜 엑박이죠 -_-;; 

수정

Copy
<?php } else {
$thumb = get_list_thumbnail($board['bo_table'], $list[$i]['wr_id'], $board['bo_gallery_width'], $board['bo_gallery_height'], false, true);

          if($thumb['src']) {
            $img_content = '<img src="'.$thumb['src'].'" alt="'.$thumb['alt'].'" style="width:80px; height:50px;">';
           } else {
           $img_content = '<div class="no_image" style="margin-left:5px; width:80px; height:50px; line-height:50px; text-align:center; border:1px solid #00495f">no image</div>';
            }
    //echo $img_content;


$img_src = $thumb; 
$imgbinary = fread(fopen($img_src, "r"), filesize($img_src)); 
$img_str = base64_encode($imgbinary); 
echo '<img src="data:img/jpg;base64,'.$img_str.'" />';


 }
 ?>
 

에디터 이미지는 암호화 처리못하나요?

|

답변 2개

채택된 답변
+20 포인트
2019-04-15 (월) 10:53:51

<?
 function getImageDataFromUrl($url)
{
    $urlParts = pathinfo($url);
    $extension = $urlParts['extension'];
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    $response = curl_exec($ch);
    curl_close($ch);
    $base64 = 'data:image/' . $extension . ';base64,' . base64_encode($response);
    return $base64;

}
?>
<img src="<?echo getImageDataFromUrl($img_src)?>">

curl 이용해서 할수도 있지요. 

당연히 못합니다.

이미지 데이터는 string data가 아닙니다.

base64_encode는 string data 용 함수입니다.

그리고 이미지 다운로드 막으실려면 다른 방법을 택하셔야 합니다.

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