Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Using the curl driver of the Request class
  • I can't seem to properly download remote images using the curl driver. The image saves but it's not viewable.
    $url = 'http://fuelphp.com/addons/default/themes/fuel/img/twitter_bird.png';
      $img = fopen(DOCROOT.'img/'.basename($url),'wb');
      Request::forge($url,array(
       'driver'=>'curl',
       'set_options'=>array(
        CURLOPT_FILE=>$img,
        CURLOPT_HEADER=>0)
       ))->execute();
      fclose($img);
    
  • I'm having the same problem. Tried Fuel versions 1.3 and 1.4.
  • Well, CURLOPT_FILE seems to be overridden, and \Request::forge() is returning the data. If you try your option, it'll return nothing. This actually has the image data inside $data and writes fine.

    $url = 'http://fuelphp.com/addons/shared_addons/themes/fuel/img/logo.png';
    $data = \Request::forge($url, array('driver' => 'curl', 'set_options' => array(CURLOPT_HEADER => false)))->execute();
    file_put_contents(basename($url), $data);
  • The Request class is designed to return a response, so this is the correct way of doing things.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion