티스토리 뷰
<?
if($_GET[p]) {
$tUrl = $_GET[p]; //가져올 이미지의 주소
$rUrl = $_GET[r]; //Referer
$path_parts = pathinfo($tUrl);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $tUrl);
curl_setopt($ch, CURLOPT_REFERER, $rUrl);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 1.1.4322; .NET CLR 3.0.04506.30) '); //브라우저 종류 - Explorer 7.0
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
$f = curl_exec($ch);
curl_close($ch);
$len = strlen($f);
header("Content-type: image/jpeg"); //.jpg 만 지원.. gif, png 등은 $tUrl을 파싱하여 적절히 조치하면 됨..
header("Content-Disposition: attachment; filename=".$path_parts['basename']); //우클릭으로 저장할 때 bmp 로 저장되는 문제 해결
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".$len);
echo ($f);
}
?>
- 안내
- 궁금한 점을 댓글로 남겨주시면 답변해 드립니다.