그누보드5에서 프로필 사진을 등록하려고하는데요 > 질문과 답변

본문 바로가기

질문과답변

[해결중] 그누보드5에서 프로필 사진을 등록하려고하는데요

본문

//----------------------------------------------------------
// 프로필 이미지 파일 업로드 시작
//----------------------------------------------------------
$mb_profile_img = '';
if (isset($_FILES['mb_profile_img']) && is_uploaded_file($_FILES['mb_profile_img']['tmp_name'])) {
    $mb_profile_img_ext = array_pop(explode(".", strtolower($_FILES['mb_profile_img']['name'])));

    if(@ereg($mb_profile_img_ext, "gif|jpg|jpeg|png")) {
        // 아이콘 용량이 1 MB 이하만 업로드 가능 (용량을 조정하고 싶으면 아래 수치 조정)
        if ($_FILES['mb_profile_img']['size'] <= (10 * 1024 * 1024)) {

            $dest_path_raw = G5_DATA_PATH."/member/profile/".$mb_id."_raw.".$mb_profile_img_ext;
            move_uploaded_file($_FILES['mb_profile_img']['tmp_name'], $dest_path_raw);
            $dest_path = G5_DATA_PATH."/member/profile/".$mb_id.".jpg";

            $size = getimagesize($dest_path_raw);
            if ($size[2] == 1 || $size[2] == 2 || $size[2] == 3) { // 이미지 파일이 진짜인지 판별
                if($size[0] < 320 || $size[1] < 320) { // 이미지 사이즈가 너무 작을 경우
                    $msg .= '이미지 크기가 너무 작습니다. 가로세로 320픽셀 이상의 이미지를 올려주세요.';
                } else {
                    if(file_exists($dest_path)) { // 이미 파일이 있을 경우(즉 수정일 경우) 먼저 파일을 삭제
                        @unlink($dest_path);
                    }

                    // 이미지 불러와서 판 깔기(...)
                    if($size[2] == 2) {
                        $image_call = imagecreatefromjpeg($dest_path_raw);
                    } elseif($size[2] == 1) {
                        $image_call = imagecreatefromgif($dest_path_raw);
                    } elseif($size[2] == 3) {
                        $image_call = imagecreatefrompng($dest_path_raw);
                    }

                    // 업로드된 이미지 시작점 및 크기 설정 (크롭)
                    // 기본값들
                    $basic_img_w = 320;
                    $basic_img_h = 320;
                    $src_img_x = 0;
                    $src_img_y = 0;
                    $src_img_w = $size[0];
                    $src_img_h = $size[1];
                    $des_img_x = 0;
                    $des_img_y = 0;
                    $des_img_w = $basic_img_w;
                    $des_img_h = $basic_img_h; 
                    if($size[0] > $size[1]) { // 가로가 길 경우
                        $src_img_w = $size[1];
                        switch($mb_profile_img_crop) {
                            case 1:
                                break;
                            case 2:
                                $src_img_x = $size[0] - $size[1];
                                break;
                            case 3:
                                $src_img_x = (int)(($size[0] - $size[1]) / 2);
                                break;
                            case 4:
                                $src_img_w = $size[0];
                                $des_img_h = (int)($basic_img_w * ($size[1] / $size[0]));
                                $des_img_y = (int)(($basic_img_h - $des_img_h) / 2);
                                break;
                        }
                    } elseif($size[0] < $size[1]) { // 세로가 길 경우
                        $src_img_h = $size[0];
                        switch($mb_profile_img_crop) {
                            case 1:
                                break;
                            case 2:
                                $src_img_y = $size[1] - $size[0];
                                break;
                            case 3:
                                $src_img_x = (int)(($size[1] - $size[0]) / 2);
                                break;
                            case 4:
                                $src_img_h = $size[1];
                                $des_img_w = (int)($basic_img_h * ($size[0] / $size[1]));
                                $des_img_x = (int)(($basic_img_w - $des_img_w) / 2);
                                break;
                        }
                    }

                    // 트루컬러 이미지 캔버스 준비
                    $image_canvas = imagecreatetruecolor($basic_img_w,$basic_img_h);

                    // 이미지 리사이즈
                    imagecopyresampled($image_canvas, $image_call, $des_img_x, $des_img_y, $src_img_x, $src_img_y, $des_img_w, $des_img_h, $src_img_w, $src_img_h);

                    // 이미지 저장
                    imagejpeg($image_canvas, $dest_path, 80);

                    // 메모리에서 작업내용 삭제
                    imagedestroy($image_call);
                    imagedestroy($image_canvas);

                    // 원본 이미지 삭제
                    @unlink($dest_path_raw);

                    $res = $upload->upload_make_thumb("mb_profile_img", $thumb);
                    if($res) {
                        $thumb_file = $res['t_file'];
                        // 썸네일 파일명을 회원아이디로 치환
                        $rename = $mb_id.'.'.$res['ext'];
                        @rename($thumb_file, $dest_path.$rename);
                        sql_query("update {$g5[eyoom_member]} set photo = '".$rename."' where mb_id='".$mb_id."'");
                    }


                }

            } else {    // gif,jpg,png 파일이 아니면 올라간 이미지를 삭제한다.
                @unlink($dest_path_raw);
            }
        } else {
            $msg .= '프로필 이미지를 1 MB 이하로 업로드 해주십시오.';
        }

    } else {
        $msg .= $_FILES['$mb_profile_img']['name'].'은(는) 이미지 파일이 아닙니다.';
    }

if($mb_profile_img_del == 1) { // 파일 삭제에 체크가 들어온 경우
    $dest_path = G5_DATA_PATH."/member/profile/".$mb_id.".jpg";
    @unlink($dest_path);
}
//----------------------------------------------------------
// 프로필 이미지 파일 업로드 끝
//----------------------------------------------------------

 

사진은 올라가는데요 이윰 프로필 이미지에는 등록이 안되는지 프로필 사진에는 안뜨거든요 나오게 하려면 어떻게 해야할까요??

포인트 10
경험치 1,803
[레벨 4] - 진행률 76%
가입일
2015-04-11 00:45:36
서명
미입력
자기소개
http://vhost.kr

최신글이 없습니다.

최신글이 없습니다.

댓글목록2

이윰EGG님의 댓글

profile_image
그누보드의 프로필 이미지는 새로 생긴 기능으로 이미 이윰빌더에서 프로필 이미지 등록 기능이 있어 적용을 하지 않았습니다.
이에 대해 다음 패치에 그누보드 프로필 이미지로 통합해 적용할 계획이니 참고 바랍니다.

감사합니다.

지스타온님의 댓글의 댓글

이윰빌더 시즌4 질문과 답변 게시판입니다.

질문과 답변 게시판에는 가능한 이윰 관리자가 답변을 드리지 않습니다. 회원간 활성화 될수 있도록 도움 부탁드리며, 질문자는 원하는 답변이 달릴경우 꼭 채택하여 주시기 바랍니다.

상품구매 및 유료상품 문의는 1:1문의 게시판을 이용해 주시기 바랍니다.

1:1문의 바로가기 : https://eyoom.net/bbs/qalist.php

전체 13 건 - 1 페이지
번호
제목
글쓴이
채택포인트
사이트 내 전체검색