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


-
- 관련링크 : http://vhost.kr/g5/5687회 연결
본문
//----------------------------------------------------------
// 프로필 이미지 파일 업로드 시작
//----------------------------------------------------------
$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);
}
//----------------------------------------------------------
// 프로필 이미지 파일 업로드 끝
//----------------------------------------------------------
사진은 올라가는데요 이윰 프로필 이미지에는 등록이 안되는지 프로필 사진에는 안뜨거든요 나오게 하려면 어떻게 해야할까요??


최신글이 없습니다.
최신글이 없습니다.
댓글목록2
이윰EGG님의 댓글
이에 대해 다음 패치에 그누보드 프로필 이미지로 통합해 적용할 계획이니 참고 바랍니다.
감사합니다.
지스타온님의 댓글의 댓글