
php如何通过代理下载文件

如果天朝无法访问a.com/a.rarphp实现下载文件,则编写a.php脚本并将其放在海外服务器上php实现下载文件,请访问脚本路径b.com/a.php?url=http:// a.com /a.rar

文件可以下载,我怎么写这个a.php文件

------解决方案--------------------

b.com/a.php?url=http://a.com/a.rar
如果文件不大,可以这样写
$url = isset($_GET['url'])? $_GET['url'] : '';
if($url){
$content = file_get_contents($url);
if($content){
header('cache-control:public');
header('content-type:application/octet-stream');
header('content-disposition:attachment; filename='.basename($url));
echo $content;
}
}
本文来自电脑杂谈,转载请注明本文网址:
https://www.pc-fly.com/a/jisuanjixue/article-213637-1.html
让它行退为难
没钱看