对方要我提交一个url地址,然后将对账文件推送给我,我怎样才能将这个txt文件拿到放到我的硬盘(比如d盘)
http://我的域名/cpnotify?download=http://对方域名网站/xxxx/808080290000001_20100201_20100202035959.txt
http://我的域名/cpnotify?download=http://对方域名网站/xxxx/808080290000001_20100201_20100202035959.txt
调试欢乐多
$filename = rawurldecode($_GET['download']);
$c=explode("/",$filename);
header('Content-type: application/txt');
header('Content-Disposition: attachment; filename="'.end($c).'"');
readfile("$filename");
exit();
?>
2.确认1成立的话,可以用file_get_contents + fwrite 或 php_curl
首先这个txt文件名是每天都变的,而且一般是晚上生成直接给我们推送过来。我想能够当时就收到放到本地硬盘
http://我的域名/cpnotify 是你提供的 url
而在读法访问你的时候,会加上 url 参数 ?download=http://对方域名网站/xxxx/yyy.txt
此参数你可以在 http://我的域名/cpnotify 对应的程序里用 $_GET['download'] 得到
比如对应的程序是 cpnotify/index.php, 那么
<?php
$s = file_get_contents($_GET['download']);
file_put_contents(basename($_GET['download'], $s);就可以了