페이스북처럼 회원리스트를 보여주고 쪽지보내기 기능을하려는데요
관련링크
본문
while ($rank_mb2 = sql_fetch_array($result_rank2)){
$rank_list2[] = $rank_mb2;
//echo $myphoto=mb_photo($rank_list2[$k][mb_id]);
$profile_rank_path2 = "../data/member/profile/{$rank_list2[$k][mb_id]}.jpg";
$photo = array();
$photo_filename='';
$dest_path = G5_DATA_PATH.'/member/profile/';
$dest_url = G5_DATA_URL.'/member/profile/';
$permit = array('jpg','gif','png');
foreach($permit as $val) {
$photo_name = $rank_list2[$k][mb_id].'.'.$val;
$photo_file = $dest_path.$photo_name;
// 사진이 있다면 변수 넘김
if(file_exists($photo_file)) {
$photo[$k] = '<img class="user-photo" src="'.$dest_url.$photo_name.'" height=100 >';
//img-responsive
$frid[$k]=$rank_list2[$k][mb_id];
$rank2[$k]="<a href=\"{$g5[path]}/g5/plugin/test-maker/automatch.php?mb_id={$rank_list2[$k][mb_id]}\" target='_blank'>{$photo[$k]}</a>";
$k=$k+1;
}
}
}
배열이랑 사진파일이 jpg 인지 png인지 구별해서 넣어줘야하는데 잘안되느데 아시는분 계시나요??
답변 1
$img_data = getimagesize($dest_url);
switch($img_data[2]) {
case 1: $ext = gif; break;
case 2: $ext = jpg; break;
case 3: $ext = gif; break;
default: $ext = "";
}
아래 참조
https://lighthouse2.tistory.com/entry/PHP-getimagesize-%ED%95%A8%EC%88%98
!-->