Home > php教程 > PHP源码 > body text

curl downloads files to local server

不言
Release: 2018-05-29 11:02:15
Original
9016 people have browsed it

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);
Copy after login

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template