The ftp_fget() function downloads a file from the FTP server and saves it to an open file locally.
If successful, the function returns TRUE. If it fails, returns FALSE.
ftp_fget(ftp_connection,local,remote,mode,resume)
parameter | describe |
---|---|
ftp_connection | Required. Specifies the FTP connection to use. |
local | Required. Specifies an open local file where the content should be saved. |
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 start copying. The default is 0. |
This example copies text from "source.txt" to "target.txt":
<?php$source = "source.txt";$target = fopen("target.txt", "w");$conn = ftp_connect("ftp.testftp.com") or die("Could not connect");ftp_login($conn,"admin","ert456");ftp_fget($conn,$target,$source,FTP_ASCII);ftp_close($conn);?>