Home  >  Article  >  php教程  >  php curl 下载图片到本地

php curl 下载图片到本地

PHP中文网
PHP中文网Original
2016-05-25 17:06:311382browse

[PHP]代码  

<?php
//获取空间头像图片
$url = "http://qlogo2.store.qq.com/qzone/393183837/393183837/50";
$curl = curl_init($url);
$filename = date("Ymdhis").".jpg";
curl_setopt($curl,CURLOPT_RETURNTRANSFER,1);
$imageData = curl_exec($curl);
curl_close($curl);
$tp = @fopen($filename, ‘a’);
fwrite($tp, $imageData);
fclose($tp);
//phper地带 http://www.php.cn/
?>

                   

                   

Statement:
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
Previous article:peizhiNext article:php字符串转数组,支持中文