php 根据url生成图片并保存
$url = $photo; //图片路径 $path = '../'; //保存路径 $fileName = "photo.png"; //保存图片名 $ch = curl_init(); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 信任任何证书 curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); $file = curl_exec($ch); curl_close($ch); unlink('../photo.png'); //删除原有图片 $resource = fopen($path . $fileName , 'a'); fwrite($resource, $file); fclose($resource);