优酷图片链接格式:http://g4.ykimg.com/0100641F464ED3054F05D4007A1EEB1FC9EDE8-5045-C260-8592-83A8902FDD40
土豆图片链接格式:http://i1.tdimg.com/b/20111129/c77.jpg不知道如何将优酷链接作为(文件名).jpg,获取下来,并做到文件名不重复,还请高手指点,万分感谢!
土豆图片链接格式:http://i1.tdimg.com/b/20111129/c77.jpg不知道如何将优酷链接作为(文件名).jpg,获取下来,并做到文件名不重复,还请高手指点,万分感谢!
$fname=explode('/',$url);
//print_r($fname);exit;
$fname=$fname[3];
$dfile=$fname.'.jpg';
$str='Content-Disposition: attachment; filename="'.$dfile.'"';
header("Content-type: application/force-download");
header($str);
readfile($url);
curl_setopt($ch, CURLOPT_URL, 'http://g4.ykimg.com/0100641F464ED3054F05D4007A1EEB1FC9EDE8-5045-C260-8592-83A8902FDD40');
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$code = curl_exec($ch);
echo $code;注意设置一下header Content-type charset的编码,然后用正则取出图片的真实地址。