代码很简单就不多废话了,直接奉上:
<"http://www.baidu.com/img/baidu_sylogo1.gif"); function httpcopy($url, $file="", $timeout=60) { $file = empty($file) " ","%20",$url); if(function_exists('curl_init')) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); $temp = curl_exec($ch); if(@file_put_contents($file, $temp) && !curl_error($ch)) { return $file; } else { return false; } } else { $opts = array( "http"=>array( "method"=>"GET", "header"=>"", "timeout"=>$timeout) ); $context = stream_context_create($opts); if(@copy($url, $file, $context)) { //$http_response_header return $file; } else { return false; } } } "htmlcode"><form method="post"> <input name="url" size="50" /> <input name="submit" type="submit" /> </form> < "rb"); if ($file) { $newf = fopen ($newfname, "wb"); if ($newf) while(!feof($file)) { fwrite($newf, fread($file, 1024 * 8 ), 1024 * 8 ); } } if ($file) { fclose($file); } if ($newf) { fclose($newf); } ?>以上所述就是本文的全部内容了,希望大家能够喜欢。
标签:
php,远程下载到本地
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
桃源资源网 Design By www.nqtax.com
暂无“PHP实现远程下载文件到本地”评论...