는, 나는 큰 파일 (> 3기가바이트)에 오프셋 BIG에서 10킬로바이트의 블록을 읽는 데 필요한. 쓰기는 항상 추가되었으므로 오프셋이 필요하지 않습니다.
사용중인 PHP 버전 및 OS에 관계없이이 방법으로 작동합니다.
사전 필수 = 서버가 범위 검색 쿼리를 지원해야합니다. 아파치 & IIS는 이미이 지원하는 다른 웹 서버 (공유 호스팅 또는 기타)
// offset, 3GB+
$start=floatval(3355902253);
// bytes to read, 100 KB
$len=floatval(100*1024);
// set up the http byte range headers
$opts = array('http'=>array('method'=>'GET','header'=>"Range: bytes=$start-".($start+$len-1)));
$context = stream_context_create($opts);
// bytes ranges header
print_r($opts);
// change the URL below to the URL of your file. DO NOT change it to a file path.
// you MUST use a http:// URL for your file for a http request to work
// this will output the results
echo $result = file_get_contents('http://127.0.0.1/dir/mydbfile.dat', false, $context);
// status of your request
// if this is empty, means http request didnt fire.
print_r($http_response_header);
// Check your file URL and verify by going directly to your file URL from a web
// browser. If http response shows errors i.e. code > 400 check you are sending the
// correct Range headers bytes. For eg - if you give a start Range which exceeds the
// current file size, it will give 406.
// NOTE - The current file size is also returned back in the http response header
// Content-Range: bytes 355902253-355903252/355904253, the last number is the file size
...
의 99 % ...
...
보안처럼 - 당신은 htaccess로를 추가해야합니다 규칙은 로컬 IP 127.0.0.1에서 오는 것을 제외하고이 데이터베이스 파일에 대한 모든 요청을 거부합니다.
파일을 어떻게여시겠습니까? –
$ f = fopen ('data.log', 'r'); – anvoz
32 비트 또는 64 비트를 사용하고 있습니까? – Baba