SWF 파일 (플래시 게임)을 성공적으로 다운로드 할 때이 함수를 사용했습니다. 특정 사이트에이 스크립트를 사용하면 실제 크기가 299 바이트 인 모든 게임을 다운로드합니다 (목록에서 4 개의 게임을 다운로드하라는 스크립트를 말했습니까?). Google 크롬으로이 게임을 다운로드하려고 시도했지만 다운로드가 완료되었습니다. 내가 사용하는 CURL 함수에 누락 된 것이 있습니까? 아니면 다운로드 알고리즘이 충분하지 않습니까? 어떤 도움이라도 대단히 감사하겠습니다.PHP와 cURL을 사용하여 파일 다운로드
function saveFlash($fullPaths,$folder,$gamenames,$i){
$curl = curl_init($fullPaths[$i]);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
//Create a new file in the given folder
$fp = fopen($folder."/".$gamenames[$i].".swf", 'w');
if ($fp == FALSE){
echo "File not opened<br>";}
//Ask cURL to write the contents to a file
curl_setopt($curl, CURLOPT_FILE, $fp);
//Execute the cURL session
curl_exec ($curl);
//Close cURL session and file
curl_close ($curl);
fclose($fp);
}
텍스트 편집기는 다음
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>302 Found</title>
</head><body>
<h1>Found</h1>
<p>The document has moved <a href="http://www.freeonlinegames.com/">here</a>.</p>
<hr>
<address>Apache/2.2.3 (CentOS) Server at freeonlinegames.com Port 80</address>
</body></html>
299 바이트 파일을 텍스트 편집기로 보았습니까? 대부분 일종의 "죄송합니다. 직접 액세스 할 수 없습니다"라는 오류 메시지가 표시 될 수 있습니다. –
스크립트가 차단됩니다. 이유 때문에 반환 된 데이터 (HTML이어야 함)를 조사하십시오. – hakre
이 문서 – George