<?php
/* ob_start();
$filename='https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=gQF_8TwAAAAAAAAAAS5odHRwOi8vd2VpeGluLnFxLmNvbS9xLzAyeU5KY2xVRFlmY2oxMDAwME0wM0UAAgTM9aVaAwQAAAAA';
$date=date("Ymd-H:i:m");
header( "Content-type: application/octet-stream ");
header( "Accept-Ranges: bytes ");
header( "Content-Disposition: attachment; filename= aa.png");
$size=readfile($filename);
header( "Accept-Length: " .$size); */
$url = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=gQF_8TwAAAAAAAAAAS5odHRwOi8vd2VpeGluLnFxLmNvbS9xLzAyeU5KY2xVRFlmY2oxMDAwME0wM0UAAgTM9aVaAwQAAAAA";
$image_content = file_get_contents($url);
$http_type = get_headers($url);
$result = explode('/',$http_type[3]);
$type = 'png';
file_put_contents('aaa.'.$type,$image_content);