PHP保存远程图片的方法
//保存远程图片开始
$path = './public/uploads/cropimages/';//保存的路径
$img_file = $path.'start'.date("YmdHis").rand(0,100).'.jpg';
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $picurl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$img = curl_exec($ch);
curl_close($ch);
$fp2 = @fopen($img_file, "a");
@fwrite($fp2,$img);
@fclose($fp2);
unset($img);
//保存远程图片结束