Home >php教程 >PHP源码 >curl downloads files to local server

curl downloads files to local server

不言
不言Original
2018-05-29 11:02:159039browse

Jump to                                                                                                     [Full screen preview]

<?php

$source = "http://apkegg.mumayi.com/cooperation/2016/06/06/0/18/latiao_V1.1_mumayi_3dfc4.apk";

$ch = curl_init();//初始化一个cURL会话
curl_setopt($ch,CURLOPT_URL,$source);//抓取url
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);//是否显示头信息
curl_setopt($ch,CURLOPT_SSLVERSION,3);//传递一个包含SSL版本的长参数
$data = curl_exec($ch);// 执行一个cURL会话
$error = curl_error($ch);//返回一条最近一次cURL操作明确的文本的错误信息。
curl_close($ch);//关闭一个cURL会话并且释放所有资源

$destination = &#39;./latiao.apk&#39;;
$file = fopen($destination,"w+");
fputs($file,$data);//写入文件
fclose($file);

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