PHP ftp_pasv() function

definition and usage

The ftp_pasv() function sets the passive mode to open or close.

In passive mode, the data connection is initiated by the client, not the server. This is useful when the client is behind a firewall.

syntax

ftp_pasv(ftp_connection,mode)
parameter description
ftp_connection required. Specifies the FTP connection to use (identifier of the FTP connection).
mode

required. Specifies the mode.

  • TRUE = passive mode on
  • FALSE = passive mode off

description

If the parameter mode If true, open passive mode transfer (PASV MODE), otherwise, if the parameter mode If false, then turn off passive transfer mode. In passive mode, data transfer is initiated by the client, not the server.

If successful, it returns true, and if it fails, it returns false.

instance

<?php
$conn = ftp_connect("ftp.testftp.com") or die("Could not connect");
ftp_login($conn,"admin","ert456");
ftp_pasv($conn,TRUE);
ftp_close($conn);
?>