title: Error get image from url using curl?
body: <p>I have a sample code:</p>
  
  <pre><code>admin
  -index.php
  uploads
  </code></pre>
  
  <p>in index.php i using code:</p>
  
  <pre><code>function saveImageFromUrl($my_img, $fullpath){
     if($fullpath!="" &amp;&amp; $fullpath){
        $fullpath = $fullpath."/".basename($my_img);
     }
     $ch = curl_init ($my_img);
     curl_setopt($ch, CURLOPT_HEADER, 0);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
     //curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
     $rawdata=curl_exec($ch);
     curl_close ($ch);
     if(file_exists($fullpath)){
        unlink($fullpath);
     }
     $fp = fopen($fullpath,'x');
     fwrite($fp, $rawdata);
     fclose($fp);
  }
  $dir = dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR;
  $fullpath = "uploads";
  saveImageFromUrl('image.png', $dir.$fullpath);
  </code></pre>
  
  <p>And result error get image fail => how to fix it ?</p>