1
PHP로 설립 된 FTP 계약을 통해 깨진 다운로드를 재개 할 수있는 방법이 있습니까? PHP는 깨진 다운로드를 재개 할 수 있습니까?php ftp로 버려진 다운로드를 다시 시작 하시겠습니까?
PHP로 설립 된 FTP 계약을 통해 깨진 다운로드를 재개 할 수있는 방법이 있습니까? PHP는 깨진 다운로드를 재개 할 수 있습니까?php ftp로 버려진 다운로드를 다시 시작 하시겠습니까?
예, ftp_fget() 함수의 선택적 $ resumepos 매개 변수를 사용할 수 있습니다.
예 :
$remote_file_name = "/test.txt";
$local_file_name = "test.txt";
$ftp_server = "ftp.your.server";
$username = "anonymous";
$password = "[email protected]";
$ftp_stream = ftp_connect($ftp_server);
$result = ftp_login($ftp_stream, $username, $password);
if ((!$ftp_stream) || (!$result)) {
echo "FTP connection failed\n";
} else {
echo "connected to FTP\n";
}
if (file_exists($local_file_name)) {
$resume_pos = filesize($local_file_name);
} else {
$resume_pos = 0;
}
$local_file_handle = fopen($local_file_name, "w");
$result = ftp_fget($ftp_stream, $local_file_handle, $remote_file_name, FTP_BINARY, $resumepos);
fclose($local_file_handle);
ftp_close($ftp_stream);
당신이 확인해야 할 것, 그래서 당신은 파일을 재개 여부 될 필요가 있는지 확인하기 위해 ftp_size() 함수를 사용할 수 있지만, 모든 FTP 서버에서 지원되지 않습니다 그.
아주 멋지다, 감사합니다. matja –