2016-06-09 44 views
-1

我想做一个脚本来获取一个可下载的文件,并将其放到我的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

+1

获取数据为什么不'file_get_contents'或卷曲? – ceejayoz

回答

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))); 

?> 

固定它