我正在尝试制作一个脚本来获取可下载的文件并将其放到我的ftp服务器上然后更新数据库。我无法弄清楚url扩展应该是什么才能使这项工作。
<?php
$src = fopen('https://www.atf.gov/firearms/docs/0516-ffl-listxlsx/download', 'r');
$dest1 = fopen('first1k.xlsx', 'w');
$dest2 = fopen('remainder.xlsx', 'w');
echo stream_copy_to_stream($src, $dest1, 19759460) . " bytes copied to first1k.txt\n";
echo stream_copy_to_stream($src, $dest2) . " bytes copied to remainder.txt\n";
?>
这是我尝试从https://www.atf.gov/firearms/listing-federal-firearms-licensees-ffls-2016
获取数据的地方答案 0 :(得分:0)
<?php
$file = "0516.xlsx";
$url = 'https://www.atf.gov/firearms/docs/0516-ffl-listxlsx/download' ;
$handle = fopen("0516.xlsx", "w+");
fwrite($handle, file_get_contents($url));
rewind($handle);
$read = htmlentities(fread($handle, filesize($file)));
?>
修好了