getimagesize(Array) [function.getimagesize]: failed to open stream: No such file or directory > 그누4 질문답변

그누4 질문답변

그누보드4 관련 질문은 QA 로 이전됩니다. QA 그누보드4 바로가기
기존 게시물은 열람만 가능합니다.

getimagesize(Array) [function.getimagesize]: failed to open stream: No such file or directory 정보

getimagesize(Array) [function.getimagesize]: failed to open stream: No such file or directory

본문

외부 링크로 퍼온 이미지라도 경로에 data/cheditor4가 들어가면

썸네일을 추출하려고 해서 오류가 나는것 같습니다.

이미지 경로에 data/cheditor4가 들어간다고 해도 g4[path]로 한정시킨다던가 하면 될것 같은데..

					if (preg_match("/data\/cheditor4//썸네일 생성
$thumfile = "";
    $thumb = $thumb_path.'/'.$list[$i][wr_id];
		 if (!file_exists($thumb)) {
			$file = $list[$i][file][0][path] .'/'. $list[$i][file][0][file];
			// 업로드된 파일이 이미지라면
			if (preg_match("/\.(jp[e]?g|gif|png)$/i", $file) && file_exists($file)) {
				$size = getimagesize($file);
				if ($size[2] == 1)
					$src = imagecreatefromgif($file);
				else if ($size[2] == 2)
					$src = imagecreatefromjpeg($file);
				else if ($size[2] == 3)
					$src = imagecreatefrompng($file);
				else
					break;

				$rate = $img_width / $size[0];
				$height = (int)($size[1] * $rate);

				// 계산된 썸네일 이미지의 높이가 설정된 이미지의 높이보다 작다면
				if ($height < $img_height)
					// 계산된 이미지 높이로 복사본 이미지 생성
					$dst = imagecreatetruecolor($img_width, $height);
				else
					// 설정된 이미지 높이로 복사본 이미지 생성
					$dst = imagecreatetruecolor($img_width, $img_height);
				imagecopyresampled($dst, $src, 0, 0, 0, 0, $img_width, $height, $size[0], $size[1]);
				imagejpeg($dst, $thumb_path.'/'.$list[$i][wr_id], $img_quality);
				chmod($thumb_path.'/'.$list[$i][wr_id], 0606);
				} else { //게디터에서 삽입한 이미지 뽑자ㅠㅠ
					$edit_img = $list[$i]['wr_content'];
					if (preg_match("/data\/cheditor4[^<>]*\.(gif|jp[e]?g|png|bmp)/i", $edit_img, $tmp)) { // data/cheditor4------
						$file = './' . $tmp[0]; // 파일명
						$file = explode("/data", $file); // 추가됨
						$file = $g4['path']."/data".$file[1]; // 추가됨
						$size = getimagesize($file);
						if ($size[2] == 1)
							$src = imagecreatefromgif($file);
						else if ($size[2] == 2)
							$src = imagecreatefromjpeg($file);
						else if ($size[2] == 3) 
							$src = imagecreatefrompng($file); 
						else
							break;

						$rate = $img_width / $size[0];
						$height = (int)($size[1] * $rate);

						// 계산된 썸네일 이미지의 높이가 설정된 이미지의 높이보다 작다면
						if ($height < $img_height)
							// 계산된 이미지 높이로 복사본 이미지 생성
							$dst = imagecreatetruecolor($img_width, $height);
						else
							// 설정된 이미지 높이로 복사본 이미지 생성
							$dst = imagecreatetruecolor($img_width, $img_height);
						imagecopyresampled($dst, $src, 0, 0, 0, 0, $img_width, $height, $size[0], $size[1]);
						imagejpeg($dst, $thumb_path.'/'.$list[$i][wr_id], $img_quality);
						chmod($thumb_path.'/'.$list[$i][wr_id], 0606);
					}
				}
			}


도움 좀 부탁드립니다.

댓글 전체

if (preg_match("/data\/cheditor4[^<>]*\.(gif|jp[e]?g|png|bmp)/i", $edit_img, $tmp)) {
                        $file = './' . $tmp[0]; // 파일명
                        $file = explode("/data", $file); // 추가됨
                        $file = $g4['path']."/data".$file[1]; // 추가됨

수정
$patt='@http://'.$_SERVER[HTTP_HOST].'(/data/cheditor[^>]+\.(gif|jp[e]?g|png))@i";
if(preg_match($patt, $list[$i]['wr_content'],$tmp) ){
$file = $g4['path']. $tmp[1];
전체 66,554 |RSS
그누4 질문답변 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1402호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT