회원가입시 프로필 사진 등록이 안되는데 도움 주실분~~ 채택완료
//----------------------------------------------------------
// 프로필 이미지 파일 업로드 시작
//----------------------------------------------------------
$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'] <= (1 * 1024 * 1024)) {
$dest_path_raw = G5_DATA_PATH."/member/profile_img/".$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_img/".$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);
}
} 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_img/".$mb_id.".jpg";
@unlink($dest_path);
}
//----------------------------------------------------------
// 프로필 이미지 파일 업로드 끝
//----------------------------------------------------------
답변 2개
등록이 안되는건지 출력이 안되는건지 확인이 먼저 필요 합니다.
위의 질문으로는 상황을 알수 없으니
우선 아래 두 폴더에 올리신 이미지가 있는지 확인을 먼저 해보세요.
/data/member
/data/member_image
사진이 없으면 업로드 문제이고 사진이 있다면 출력이 문제라고 생격 하시고 확인 해 보세요.
답변에 대한 댓글 2개
그누보드 원본으로는 <?php echo get_member_profile_img($list[$i]['mb_id']); ?> 이소스가 프로필 이미지가 출력되는 코드 입니다.
댓글을 작성하려면 로그인이 필요합니다.
감사드립니다. 그누프로필 사진 기능이 추가가 되었군요. 이윰이랑 그누랑 호환이 잘안되니 이또한 문제군요. 흑흑
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인
$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."'");