Home >Backend Development >PHP Tutorial >thinkpad x200 7457 uses the Http class that comes with ThinkPHP to download remote images to the local implementation code
The Http class is under the directory ThinkPHP/Lib/ORG/Net. Next let's see how it is called.
Copy the code The code is 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'];
}
}
?>
to copy the code The code is as follows:
Http::curl_download($remoteUrl['ImageURL'], "./".$localUrl);
The above introduces the implementation code of thinkpad x200 7457 using the Http class that comes with ThinkPHP to download remote images to the local area, including the content of thinkpad x200 7457. I hope it will be helpful to friends who are interested in PHP tutorials.