코멘트에 이미지 추가

· 2009-09-03 (목) 22:47:00 · 9284 · 9



resize_content 함수를 쓸수있는 불당썸이 있어야합니다 아닐경우 아래 resize_content 부분을 따로 수정하세요

write_comment_update.skin.php

코멘트 내용출력 echo $str 전에 추가 합니다.
<?
    $aaafile="";
    $aaa="";
    $aaafile = get_file($bo_table, $comment_id);
    if($aaafile[0][view] && $aaafile[0][file])$aaa=$aaafile[0][view];
    elseif($aaafile[0][file]) $aaa="
    echo resize_content("$aaa",400);
    if($aaa)echo"<br />";

?>

코멘트 입력 히든폼 부분에 추가 합니다
<input type="hidden" name="picname" value="<?=$aaafile[0][file]?>" />

코멘트 입력폼 적당한 부분에 추가 합니다
사진첨부 : <input type="file" name="comment_file" size="10" />
  <? if (file_exists("$g4[path]/data/file/$bo_table/{$aaafile[0][file]}")) { ?>
  <input type="checkbox" name="compic" value="1" />첨부삭제
  <?}?>




아래 코드를  write_comment_update.tail.skin.php 파일로 저장해 해당 스킨 폴더에 넣습니다
<?

// 삭제에 체크가 되어있다면 파일을 삭제합니다.
if ($compic)
{

        $row = sql_fetch(" select bf_file from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$comment_id' and bf_no = '0' ");
        @unlink("$g4[path]/data/file/$bo_table/$picname");
  sql_query("delete from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$comment_id' ");

}
else
{
 $row = sql_fetch(" select count(*) as cnt from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$comment_id'");
 if($row && is_uploaded_file($_FILES[comment_file][name]))alert("이미 파일이 존재 합니다. 기존 파일을 삭제하기위해 파일삭제를 체크 해주세요");
}

$ffname = md5($g4[time_ymdhis]).".jpg";

if(is_uploaded_file($_FILES[comment_file][tmp_name])) {

    $tmp_file  = $_FILES[comment_file][tmp_name];
    $filename  = $_FILES[comment_file][name];
    $filesize  = $_FILES[comment_file][size];

if(ereg("\.jpg", strtolower($_FILES[comment_file][name])))$tagggs =  1;
if(ereg("\.gif", strtolower($_FILES[comment_file][name])))$tagggs =  1;
if(ereg("\.png", strtolower($_FILES[comment_file][name])))$tagggs =  1;

if(!$tagggs)alert("이미지 파일이 아닙니다. 혹은 BMP파일은 업로드 할 수 없습니다.");


        if ($filesize > 400000)
        {
            $file_upload_msg .= "\'{$filename}\' 파일의 용량(".number_format(400000)." 바이트)이 게시판에 설정(".number_format(400000)." 바이트)된 값보다 크므로 업로드 하지 않습니다.\\n";
            alert("$file_upload_msg");
        }

        $dest = "$g4[path]/data/file/$bo_table/".$ffname;
move_uploaded_file($_FILES[comment_file][tmp_name], "$dest");
        $imagesize = @getimagesize($dest);
        $sql = " insert into $g4[board_file_table]
                    set bo_table = '$bo_table',
                        wr_id = '$comment_id',
                        bf_no = '0',
                        bf_source = '$ffname',
                        bf_file = '$ffname',
                        bf_content = '{$bf_content}',
                        bf_download = 0,
                        bf_filesize = '$filesize',
                        bf_width = '{$imagesize[0]}',
                        bf_height = '{$imagesize[1]}',
                        bf_type = '{$imagesize[2]}',
                        bf_datetime = '$g4[time_ymdhis]' ";
        sql_query($sql);

}
?>

|

댓글 9개

2009-09-04 (금) 04:00:15
굿!! 아이디어!!! 추천 쾅쾅쾅!!!
2009-10-07 (수) 00:42:13
좋은정보감사합니다.
ggg
저만 않되는 건가요?? ㅠㅠ
write_comment_update.skin.php
echo $str <- 없어요...ㅠㅠ
억지로 해보니, 하얀 페이지만 나와요...ㅠㅠ
2012-01-30 (월) 21:21:32
<?
$aaafile="";
$aaa="";
$aaafile = get_file($bo_table, $comment_id);
if($aaafile[0][view] && $aaafile[0][file])$aaa=$aaafile[0][view];
elseif($aaafile[0][file]) $aaa="
echo resize_content("$aaa",400); -----요라인과
if($aaa)echo"<br />"; -----------요라인에서 구문 에러가남 해결좀

?>
2013-02-02 (토) 10:25:24
불당썸이 없군요
사랑하기님 댓글 부분에 에러 납니다.
2013-01-15 (화) 15:50:52
게시물이 삭제되면 첨부파일은 남는것 아닌가요??
일부러 꼬아놓으신건지...
저는 개발자라 다행인지ㅎㅎㅎㅎ
오류 몇개 해결하니까 되네요.
그리고, 불당썸 아니고 불당 리사이즈...
댓글을 작성하시려면 로그인이 필요합니다.

그누4 팁자료실

3,309건

그누보드4와 관련된 팁을 여러분들과 함께 공유하세요. 나누면 즐거움이 커집니다.

+
제목 글쓴이 날짜 조회
09-09-14 조회 4,919
09-09-12 조회 4,254
09-09-11 조회 4,197
09-09-09 조회 7,893
09-09-07 조회 4,646
09-09-07 조회 3,889
09-09-07 조회 5,582
09-09-06 조회 3,475
09-09-05 조회 3,382
09-09-04 조회 3,524
09-09-04 조회 2,862
09-09-04 조회 3,166
09-09-04 조회 3,259
09-09-03 조회 9,285
09-09-03 조회 3,834
09-09-02 조회 3,705
09-09-02 조회 4,018
09-09-01 조회 5,596
09-08-31 조회 4,486
09-08-30 조회 3,265