修改图片文件名参数

WBOY
Release: 2016-06-13 13:47:50
Original
1012 people have browsed it

求一个修改图片文件名参数
求一个CURL保存远程图片到本地服务器参数
下面代码是一段CURL获取图片并保存图片的参数,小弟不才,刚接触php。
现在要解决的问题是,如何 $tp = @fopen('123.jpg', 'a); 将这个123.jpg参数修改成 以时间命名的文件
$url = 'http://app.qlogo.cn/mbloghead/6e033128b37c1223af52/180.jpg';
$curl = curl_init($url);
$m = date('Y年m月d日',time()+(60*60*8));
curl_setopt($curl, CURLOPT_REFERER, 'http://app.qlogo.cn');
curl_setopt($curl,CURLOPT_RETURNTRANSFER,1);
//是否显示内容
$imageData = curl_exec($curl); curl_close($curl);
//保存图片
$tp = @fopen('123.jpg', 'a);
fwrite($tp, $imageData);
fclose($tp);
?>

------解决方案--------------------
$url = 'http://app.qlogo.cn/mbloghead/6e033128b37c1223af52/180.jpg';
$curl = curl_init($url);
$m = date('Ymdhis').".jpg";
curl_setopt($curl, CURLOPT_REFERER, 'http://app.qlogo.cn');
curl_setopt($curl,CURLOPT_RETURNTRANSFER,1);
//是否显示内容
$imageData = curl_exec($curl); curl_close($curl);
//保存图片
$tp = @fopen($m, 'a');
fwrite($tp, $imageData);
fclose($tp);
?>

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!