title: Saving a remote image with cURL?
body: <p>Morning all, </p>
  
  <p>Theres a few questions around this but none that really answer my question, as far as I ca understand. Basically I have a GD script that deals with resizing and caching images on our server, but I need to do the same with images stored on a remote server.</p>
  
  <p>So, I'm wanting to save the image locally, then resize and display it as normal. </p>
  
  <p>I've got this far...</p>
  
  <pre><code>        $file_name_array = explode('/', $filename);
          $file_name_array_r = array_reverse($file_name_array);  
  
          $save_to = 'system/cache/remote/'.$file_name_array_r[1].'-'.$file_name_array_r[0];
  
          $ch = curl_init($filename);
          $fp = fopen($save_to, "wb");
  
          // set URL and other appropriate options
          $options = array(CURLOPT_FILE =&gt; $fp,
                           CURLOPT_HEADER =&gt; 0,
                           CURLOPT_FOLLOWLOCATION =&gt; 1,
                           CURLOPT_TIMEOUT =&gt; 60); // 1 minute timeout (should be enough)
  
          curl_setopt_array($ch, $options);
  
          curl_exec($ch);
          curl_close($ch);
          fclose($fp);
  </code></pre>
  
  <p>This creates the image file, but does not copy it accross? Am I missing the point?</p>
  
  <p>Cheers guys. </p>