2016-06-09 3 views
-1

다운로드 가능한 파일을 가져 와서 내 ftp 서버에 올려서 데이터베이스를 업데이트하는 스크립트를 만들려고합니다. 나는 url 확장이이 작업을 할 수 있어야한다는 것을 알아낼 수 없다.숨겨진 다운로드 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))); 

?> 

관련 문제