PHP ile bir görüntü indirmek için?

2 Cevap php

Görüntünün url burada varsayalım:

http://sstatic.net/so/img/logo.png

PHP ile indirmek için?

2 Cevap

Sen bir kıvrılma isteği kullanabilirsiniz:

public static function curlGet($url)
{
  $ch = curl_init($url);
  curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
  curl_setopt($ch, CURLOPT_HEADER, 0);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  $content = curl_exec($ch);
  curl_close($ch);
  return $content;
}

ve bir dosyaya içerik yanıt yazmak

$fp = fopen('logo.png', 'w');
fwrite($fp, curlGet('http://sstatic.net/so/img/logo.png') );
fclose($fp);