WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

PHP ftp_get () function


Definition and usage

The ftp_get () function downloads a file from an FTP server and saves it to a local file.

If successful, the function returns TRUE. If it fails, it returns FALSE.

Syntax

ftp_get (ftp_connection, local, remote, mode, resume)

parameters description
ftp_connection Required. Specifies the FTP connection to use.
local Required. Specifies a local file to save the content. If the file already exists, it is overwritten.
remote Required. Specifies the path of the file from which content is copied.
mode Required. Specify the transmission mode. Possible values ​​are:
  • FTP_ASCII
  • FTP_BINARY
resume Optional. Specifies where in the remote file to start copying. The default is 0.


Example

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");

echo ftp_get($conn,"target.txt","source.txt",FTP_ASCII);

ftp_close($conn);
?>

The above code will output:

1