Home > Backend Development > PHP Tutorial > php怎么实现代理下载文件

php怎么实现代理下载文件

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 12:06:14
Original
1516 people have browsed it

php如何实现代理下载文件
假如a.com/a.rar在天朝无法访问,如果写一个a.php脚本,放在海外服务器上,访问脚本路径b.com/a.php?url=http://a.com/a.rar
就可以实现文件下载了,请问这个a.php文件怎么写
------解决方案--------------------
b.com/a.php?url=http://a.com/a.rar
如果文件不大可以这样写

<br />$url = isset($_GET['url'])? $_GET['url'] : '';<br /><br />if($url){<br />    $content = file_get_contents($url);<br />    if($content){<br />        header('cache-control:public');<br />        header('content-type:application/octet-stream');<br />        header('content-disposition:attachment; filename='.basename($url));<br />        echo $content;<br />    }<br />}<br />
Copy after login

Related labels:
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