Kendi resim indirme scriptimde 3 farklı yöntem kullanmışım, hangisiyle iniyorsa onu deniyor

fopen fwrite fclose

file_put_contents , file_get_contents

copy

Tabi detaylı işlemler var scriptin içinde ama sırf o bölümü atıyorum.

Edit: function ile beraber attım bu çağrılırsa php dosyasının olduğu yere resmi çeker mesela.
        

$media_dosya_yukle = "media.gif";
$gelen_getdata_url = "https://cdn.r10.net/image.php?u=128162";



   function getRequest($url, $refer = "", $timeout = 30)
   {
      $ssl = stripos($url,'https://') === 0 ? true : false;
      $curlObj = curl_init();
      $options = [
          CURLOPT_URL => $url,
          CURLOPT_RETURNTRANSFER => 1,
          CURLOPT_FOLLOWLOCATION => 1,
          CURLOPT_AUTOREFERER => 1,
          CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0',
          CURLOPT_SSL_VERIFYPEER => 0,
          CURLOPT_TIMEOUT => $timeout,
          CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_0,
          CURLOPT_HTTPHEADER => ['Expect:'],
          CURLOPT_IPRESOLVE => CURL_IPRESOLVE_V4,
      ];
      if ($refer) {
          $options[CURLOPT_REFERER] = $refer;
      }
      if ($ssl) {
          //support https
          $options[CURLOPT_SSL_VERIFYHOST] = false;
          $options[CURLOPT_SSL_VERIFYPEER] = false;
      }
      curl_setopt_array($curlObj, $options);
      $returnData = curl_exec($curlObj);
      if (curl_errno($curlObj)) {
          //error message
          $returnData = curl_error($curlObj);
      }
      curl_close($curlObj);
      return $returnData;
   }

if($gelen_getdata_url_kontrol_sonuc = @getRequest($gelen_getdata_url))
 {
    $fp = fopen($media_dosya_yukle, 'w');
    fwrite($fp, $gelen_getdata_url_kontrol_sonuc);
    fclose($fp);
 
    $gelen_getdata_yukleme = 1;
 }
 else if(@file_put_contents($media_dosya_yukle, file_get_contents($gelen_getdata_url)))
 {
    $gelen_getdata_yukleme = 1;
 }
 else if(@copy($gelen_getdata_url, $media_dosya_yukle))
 {
    $gelen_getdata_yukleme = 1;
 }
 else
 {
    echo 1;
 }