The HTTP class is below the directory thinkphp/lib/org/net. Now let's see how it's called.
Copy the Code code as follows:
Import ("Com.Buyback.QueryAmazon");
Import ("ORG.Net.Http");
Class Image {
public static function GetImage ($ISBN) {
$bookInformModel = D ("Bookinform");
$result = $bookInformModel->where ("isbn= ' $ISBN '")->select ();
if ($result [0][' image '] = = "") {
$data [' inform_id '] = $result [0][' inform_id '];
$REMOTEURL = Queryamazon::getimage ($ISBN);
if (!empty ($remoteUrl [' ImageURL '])) {
$LOCALURL = "public/bookcover/". $isbn. ". JPG ";
Http::curl_download ($remoteUrl [' ImageURL '], "./". $localUrl);
}else{
$LOCALURL = "Public/bookcover/unknownbook.png";
}
$data [' image '] = $LOCALURL;
$bookInformModel->save ($data);
return $LOCALURL;
}
return $result [0][' image '];
}
}
?>
Here I first determine whether the image information in the database, do not call Amazon WebService from remote to the image address, and then use
Copy the Code code as follows:
Http::curl_download ($remoteUrl [' ImageURL '], "./". $localUrl);
Where the first parameter of the Curl_download method is the remote picture address, the second parameter is the address that is saved to the local.
OK, it's so simple ~ ~
The above describes the ThinkPad X200 7457 using the thinkphp comes with the HTTP class to download the remote image to the local implementation code, including the ThinkPad X200 7457 aspects of the content, I hope to be interested in PHP tutorial friends helpful.