외부 이미지 저장
[code]
function save_web_image($url, $saveName) {
if (strstr($url, "//")) {
$a = explode("//", $url);
$url = $a[1];
}
$a = explode("/", $url);
$host = $a[0];
$path = "";
for ($i = 1; $i < count($a); $i++)
$path .= "/".$a[$i];
$fp = fsockopen($host, 80, $errno, $errstr, 10);
if ($fp) {
$send = "GET $path HTTP/1.1\r\n";
$send.= "Host: $host\r\n";
$send.= "Connection: Close\r\n\r\n";
fwrite($fp, $send);
$content = "";
while (!feof($fp))
$content .= fread($fp, 1024);
$content = substr($content, strpos($content, "\r\n\r\n") + 4);
fclose($fp);
$im = imagecreatefromstring($content);
imagegif($im, $saveName);
return $saveName;
}
return "";
}
[/code]
allow_url_fopen 막힌 곳도 잘 됩니다.
게시판 목록
개발자팁
질문은 QA에서 해주시기 바랍니다.
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 4346 | PHP | 8년 전 | 5196 | ||
| 4345 | PHP | 8년 전 | 1978 | ||
| 4344 | PHP | 8년 전 | 2095 | ||
| 4343 | PHP | 8년 전 | 2133 | ||
| 4342 | 기타 |
프로그래머7
|
8년 전 | 2951 | |
| 4341 | PHP | 8년 전 | 2306 | ||
| 4340 | PHP | 8년 전 | 2454 | ||
| 4339 | PHP | 8년 전 | 2872 | ||
| 4338 | PHP | 8년 전 | 2583 | ||
| 4337 | PHP | 8년 전 | 3061 | ||
| 4336 | PHP | 8년 전 | 2467 | ||
| 4335 | PHP | 8년 전 | 2113 | ||
| 4334 | PHP | 8년 전 | 2507 | ||
| 4333 | PHP | 8년 전 | 2565 | ||
| 4332 | PHP | 8년 전 | 5042 | ||
| 4331 | PHP | 8년 전 | 2554 | ||
| 4330 | PHP | 8년 전 | 2189 | ||
| 4329 | PHP | 8년 전 | 2727 | ||
| 4328 | PHP | 8년 전 | 2131 | ||
| 4327 | PHP | 8년 전 | 2235 | ||
| 4326 | PHP | 8년 전 | 3534 | ||
| 4325 | PHP | 8년 전 | 2301 | ||
| 4324 | PHP | 8년 전 | 3241 | ||
| 4323 | PHP | 8년 전 | 2109 | ||
| 4322 | PHP | 8년 전 | 2481 | ||
| 4321 | PHP | 8년 전 | 2561 | ||
| 4320 | PHP | 8년 전 | 3494 | ||
| 4319 | PHP | 8년 전 | 3395 | ||
| 4318 | PHP | 8년 전 | 4605 | ||
| 4317 | PHP | 8년 전 | 2568 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기