zonglonglong
function saveImage($path) {
 if(!preg_match(\'/\/([^\/]+\.[a-z]{3,4})$/i\',$path,$matches))
 die(\'Use image please\');
 $image_name = strToLower($matches[1]);
 $ch = curl_init ($path);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
 $img = curl_exec ($ch);
 curl_close ($ch);
//$image_name就是要保存到什么路径,默认只写文件名的话保存到根目录
$fp = fopen($image_name,\'w\');//保存的文件名称用的是链接里面的名称 fwrite($fp, $img); fclose($fp); } saveImage(\'http://www.jb51.net/images/logo.gif\');

 如果是https的话,就加上这两句


curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);    // https请求 不验证证书和hosts
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2021-11-10
  • 2021-04-29
  • 2022-12-23
  • 2021-12-09
  • 2022-12-23
  • 2021-11-27
猜你喜欢
  • 2021-12-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-09
  • 2022-12-23
相关资源
相似解决方案