Download / Display external url image

WE HAVE MOVED!

Please visit our new Drupal Website at https://www.xenyo.com我們的新網頁設計公司網頁.

   $image = file_get_contents('http://www.xxxx.com/xxx.png');  
   $file = file_save_data($image, 'public://' . filename ,FILE_EXISTS_REPLACE); 
   $node->field_image[LANGUAGE_NONE]['0']['fid'] = $file->fid; // save image into node field
 
/***************/
$option = array('method' => 'post');
$result = drupal_http_request('http://www.xxxx.com/xxx.png', $option);
if ($result->code == 200) {
  print $result -> data; //display 
}
Help Share this Article