PHP.nl

ftp_nb_fget

ftp_nb_fget

Retrieves a file from the FTP server and writes it to an open file (non-blocking)

int **ftp_nb_fget** FTP\Connection $ftp resource $stream string $remote_filename int $mode int $offset
retrieves a remote file from the FTP 

server. ftp_nb_fget

The difference between this function and is that this function retrieves the file asynchronously, so your program can perform other operations while the file is being downloaded. ftp_fget

ftp``streamAn open file pointer in which we store the data.

remote_filenameThe remote file path.

mode The transfer mode. Must be either or . FTP_ASCII``FTP_BINARY

offsetThe position in the remote file to start downloading from.

Returns or or . FTP_FAILED``FTP_FINISHED``FTP_MOREDATA

Voorbeeld: example

<?php

// open some file for writing
$file = 'index.php';
$fp = fopen($file, 'w');

$ftp = ftp_connect($ftp_server);

$login_result = ftp_login($ftp, $ftp_user_name, $ftp_user_pass);

// Initiate the download
$ret = ftp_nb_fget($ftp, $fp, $file, FTP_BINARY);
while ($ret == FTP_MOREDATA) {

   // Do whatever you want
   echo ".";

   // Continue downloading...
   $ret = ftp_nb_continue($ftp);
}
if ($ret != FTP_FINISHED) {
   echo "There was an error downloading the file...";
   exit(1);
}

// close filepointer
fclose($fp);
?>

ftp_nb_get``ftp_nb_continue``ftp_fget``ftp_get