외부 이미지 저장
[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에서 해주시기 바랍니다.
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 4376 | PHP | 8년 전 | 2095 | ||
| 4375 | PHP | 8년 전 | 1830 | ||
| 4374 | PHP | 8년 전 | 1934 | ||
| 4373 | PHP |
|
8년 전 | 3631 | |
| 4372 | PHP | 8년 전 | 4225 | ||
| 4371 | PHP | 8년 전 | 2898 | ||
| 4370 | PHP | 8년 전 | 2285 | ||
| 4369 | PHP | 8년 전 | 4172 | ||
| 4368 | PHP | 8년 전 | 2314 | ||
| 4367 | PHP | 8년 전 | 2102 | ||
| 4366 | PHP |
|
8년 전 | 4503 | |
| 4365 | PHP |
|
8년 전 | 2775 | |
| 4364 | PHP | 8년 전 | 2091 | ||
| 4363 | PHP | 8년 전 | 2559 | ||
| 4362 | PHP | 8년 전 | 2225 | ||
| 4361 | PHP |
|
8년 전 | 2645 | |
| 4360 | PHP | 8년 전 | 2149 | ||
| 4359 | PHP | 8년 전 | 2532 | ||
| 4358 | PHP | 8년 전 | 2228 | ||
| 4357 | PHP | 8년 전 | 2345 | ||
| 4356 | PHP | 8년 전 | 2190 | ||
| 4355 | PHP | 8년 전 | 2524 | ||
| 4354 | PHP |
|
8년 전 | 2651 | |
| 4353 | PHP | 8년 전 | 3254 | ||
| 4352 | PHP | 8년 전 | 2353 | ||
| 4351 | PHP | 8년 전 | 2393 | ||
| 4350 | PHP | 8년 전 | 2358 | ||
| 4349 | PHP |
|
8년 전 | 2748 | |
| 4348 | PHP | 8년 전 | 2322 | ||
| 4347 | PHP | 8년 전 | 2016 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기