The ftp_nb_get() function downloads a file from the FTP server and saves it to a local file. (no blocking)
This function returns one of the following values:
FTP_FAILED (send/get failed)
FTP_FINISHED (send/get successful)
FTP_MOREDATA (send/get in progress)
Unlike ftp_get(), this function obtains the file asynchronously. This means your program can perform other operations while the file is downloading.
ftp_nb_get(ftp_connection,local,remote,mode,resume)
parameter | describe |
---|---|
ftp_connection | Required. Specifies the FTP connection to use. |
local | Required. Specifies a local file where the content is to be saved. If the file already exists, it is overwritten. |
remote | Required. Specifies the path to the file from which to copy content. |
mode | Required. Specifies the transmission mode. Possible values: FTP_ASCII FTP_BINARY |
resume | Optional. Specifies where in the remote file to begin copying. The default is 0. |
This example copies text from "source.txt" to "target.txt":
<?php$conn = ftp_connect("ftp.testftp.com") or die("Could not connect");ftp_login($conn,"admin","ert456");ftp_nb_get($conn,"target.txt" ,"source.txt",FTP_ASCII);ftp_close($conn);?>