채택완료

우리가 남이가? - <고수용버전>

이렇게 말하면 

거의 모든 분이 남이라고 하시더라구요,,유유

암튼 늘 껄쩍지근한 질문만 드려서 미안합니다. 

파일업로드 갯수를 늘릴려면 어떻게 해야 하나요?

날짜를 2016-07-26 이렇게 나오게 하려면요? 

이런 질문들도 간혹 해야 하는데...유유

또 날짜가 바꿨군요,,,좋은 하루 되세요,..

질문: 댓글에서 체디터5로 멀티사진창에서 이미지를 업로드하는데...

이게 파일명이 랜덤으로 저장되어 리스트에 섬네일로 불러오려는데 

장난이 아닙니다.

(간단한) 방법이 있을까요?

체디터 업로드.php를 보니 이렇게 되어 있더군요..

<?php

// ---------------------------------------------------------------------------

//                              CHXImage

//

// 이 코드는 데모를 위해서 제공됩니다.

// 환경에 맞게 수정 또는 참고하여 사용해 주십시오.

//

// ---------------------------------------------------------------------------

require_once("_config.php");

//----------------------------------------------------------------------------

//

//

$tempfile = $_FILES['file']['tmp_name'];

$filename = md5($_SERVER['REMOTE_ADDR']).'_'.$_FILES['file']['name'];

// 저장 파일 이름

// md5(IP)_년월일시분초_랜덤문자4자.확장자

// 1234567890abcdef1234567890abcdef_20140327125959_abcd.jpg

$savefile = SAVE_DIR . '/' . $filename;

// 사용자PC의 파일 이름: $_POST["origName"]

// 사용자PC의 파일 경로: $_POST["filePath"]

// 사용자PC의 파일 크기: $_POST["filesize"]

// 파일의 확장자가 이미지가 아니라면 삭제

if (!preg_match("/.(gif|jpe?g|png)$/i", $savefile))

    unlink($savefile);

move_uploaded_file($tempfile, $savefile);

$imgsize = getimagesize($savefile);

$filesize = filesize($savefile);

if (!$imgsize) {

$filesize = 0;

$random_name = '-ERR';

unlink($savefile);

};

switch ($imgsize[2]) {

    case IMAGETYPE_GIF :    // 1

    case IMAGETYPE_JPEG :   // 2

    case IMAGETYPE_PNG :    // 3

        break;

    default :

        $filesize = 0;

        $random_name = '-ERR';

        unlink($savefile);

}

$rdata = sprintf('{"fileUrl": "%s/%s", "filePath": "%s", "fileName": "%s", "fileSize": "%d" }',

SAVE_URL,

$filename,

$savefile,

$filename,

$filesize );

echo $rdata;

?>


|

답변 2개 / 댓글 18개

채택된 답변
+20 포인트

대충 불러오는 방식은

Copy
$query = " select wr_content from ".$write_table." where wr_parent = '".$wr_id."' and wr_is_comment > 0 ";/*한개의 글만 검사 할 때*/ $row = sql_fetch($query);echo get_view_thumbnail($row['wr_content']);/*한개의 글만 검사 할 때*/ /*여러개의 글 검사 할 때*/$result = sql_query($query); for($i=0; $row = sql_fetch_array($result); $i++) {  echo get_view_thumbnail($row['wr_content']);}/*여러개의 글 검사 할 때*/
 

답변에 대한 댓글 12개

get_view_thumbnail() 함수는 내용 또는 이미지 와 width값을 넣을 수 있게 되어있는 함수 입니다.
/lib/thumbnail.lib.php 보시면 됩니다
친절한 설명 감사합니다..
개념이 없어 이해는 어렵지만..ㅋ
본문 첨부파일 이미지는 이렇게 불러오던데..
제가 하고자 하는거는 어떻게 불러올지 어렵네요..
<?php
if (!$list[$i]['is_notice']) {
$thumb = get_list_thumbnail($board['bo_table'], $list[$i]['wr_id'], $board['bo_gallery_width'], $board['bo_gallery_height']);

if($thumb['src']) {
$img_content = '<img src="'.$thumb['src'].'" alt="'.$thumb['alt'].'" width="'.$board['bo_gallery_width'].'" height="'.$board['bo_gallery_height'].'" class="list_img">';
} else {
$img_content = '<img src="'.$board_skin_url.'/img/noimage.gif" width="'.$board['bo_gallery_width'].'" height="'.$board['bo_gallery_height'].'" class="list_img">';
}
echo $img_content;
}
?>
그냥은 안돼고 위처럼 쿼리를 새로 날려서 댓글의 번호를 불러와야 합니다.
위 문장중 한개의 글만 검사할때는 빼고
여러개의 글 검사할때의 문장을 가져다가 적용시키세요
$wr_id 값만 $list[$i]['wr_id']로 바꾸면 되겠네요

위 쿼리를 if 닫히는 부분 위쪽에 넣어 주시면 되겠네요
네,,늘 감사합니다. 해볼게요,,!!
죄송한데요,,if닫히는 부분위라면 정확히 어느위치를 말씀하시는지 핵갈리네요,,
f (!$list[$i]['is_notice']) {

}
이렇게 했더니 무한 로딩 걸리는군요,,,
<a href="<?php echo $list[$i]['href'] ?>">
<?php
if (!$list[$i]['is_notice']) {

$query = " select wr_content from ".$write_table." where wr_parent = '".$list[$i]['wr_id']."' and wr_is_comment > 0 ";

/*여러개의 글 검사 할 때*/
$result = sql_query($query);
for($i=0; $row = sql_fetch_array($result); $i++) {
echo get_view_thumbnail($row['wr_content']);
}
/*여러개의 글 검사 할 때*/

$thumb = get_list_thumbnail($board['bo_table'], $list[$i]['wr_id'], $board['bo_gallery_width'], $board['bo_gallery_height']);
if($thumb['src']) {
$img_content = '<img src="'.$thumb['src'].'" alt="'.$thumb['alt'].'" width="'.$board['bo_gallery_width'].'" height="'.$board['bo_gallery_height'].'" class="list_img">';
} else {
$img_content = '<img src="'.$board_skin_url.'/img/noimage.gif" width="'.$board['bo_gallery_width'].'" height="'.$board['bo_gallery_height'].'" class="list_img">';
}
echo $img_content;
}
?>
</a>
얼~~~
for 구문내의 $i 를 $j 나 이런걸로 바꾸셔야죠
$i 로 쓰면 문제가 생기겠지요 ㅡㅡ
그렇군요,,j로 바꿨더니 무한로딩은 안걸리는데,,이제 섬네일이 아니고 원본이 짠하고 등장하네요,,ㅋ
그리고 글 코멘트내용까지 리스트에 나타나구요,,,이건 또 어떻게 손봐야 하나..유유, 쉽지 않네요.,
흠 그러면 get_view_thumbnail() 를 다른이름으로 만들어서 수정해서 사용해야겠는데요
get_view_thumbnail 이름을 바꾸면 섬네일 립.php에서 받아오지 않아 작동이 안될거 같은데요..

thumbnail.lip.php도 함께 수정하고 뭔가 작업을 해주어야 하는거죠? 휴

어려운거 시간내주셔서 늘 고맙습니다~
복잡해져서 새로 질문을 올려봐야겠습니다~
좋은 하루되세요~
일단 함수를 복하해서 복사한 함수의 이름을 다르게 정의하고 그 함수의 내부에서 불러오는 내용부분을 안불러오게 수정하면 되겠지요

내용에 저장된 이미지를 리스트페이지에서 썸네일로 불러오고 싶다는 건가요???

답변에 대한 댓글 6개

네,,그렇습니다.
댓글에 체디터를 붙여 이미지를 올리는데...
이 이미지를 리스트에 나오게 하려고 합니다.
그 기능은 gallery 스킨의 list.skin.php 페이지에서 사용하고 있는 기능인데요.
첨부이미지 있으면 첨부이미지 뿌리고 없으면 내용에서 이미지 있으면 골라서 뿌리고
그렇군요,,,

첨부파일로 본문에 올린 이미지는 리스트에서 불러왔습니다.
그러나 댓글에서 첨부한 이미지는 어떻게 불러올지 감이 잡히지 않아서요,,
원글의 wr_id값이 댓글의 wr_parent값이에요
이걸이용해서 쿼리를 날려서 댓글의 이미지를 불러와야 합니다
댓글에 이미지가 다 들어있다면 그 이미지를 전부다 불러올건가요???
댓글 체디터에 12개 넣을 수 있던데요,,,리스트에는 6개만 불러오려고 합니다.


본문에 첨부파일로 올린거는 이런식으로 잘 불러왔는데요..
<?php
if (!$list[$i]['is_notice']) {

$thumb1 = get_list_thumbnail_test($board['bo_table'], $list[$i]['wr_id'], $board['bo_gallery_width'], $board['bo_gallery_height'], '', '', '', '', '', '0'); //첫번째파일

if($thumb1['src']) {
$img_content = '<img src="'.$thumb1['src'].'" alt="'.$thumb1['alt'].'" width="'.$board['bo_gallery_width'].'" height="'.$board['bo_gallery_height'].'">';
} else {
$img_content = '<img src="'.$board_skin_url.'/img/noimage.gif" width="'.$board['bo_gallery_width'].'" height="'.$board['bo_gallery_height'].'" class="list_img">';
}
echo $img_content;


$thumb2 = get_list_thumbnail_test($board['bo_table'], $list[$i]['wr_id'], $board['bo_gallery_width'], $board['bo_gallery_height'], '', '', '', '', '', '1'); //두번째파일
if($thumb2['src']) {
$img_content_0 = '<img src="'.$thumb2['src'].'" alt="'.$thumb2['alt'].'" width="'.$board['bo_gallery_width'].'" height="'.$board['bo_gallery_height'].'">';
} else {
$img_content_0 = '<img src="'.$board_skin_url.'/img/noimage.gif" width="'.$board['bo_gallery_width'].'" height="'.$board['bo_gallery_height'].'" class="list_img">';
}
echo $img_content_0;

}
?>
</a>

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