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 by the server. This is more useful when the client is behind a firewall.

Syntax

ftp_pasv(ftp_connection,mode)
Parameters Description
ftp_connection Required. Specifies the FTP connection to be used (identifier of the FTP connection).
mode

Required. Specifies the mode.

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

Description

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

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

Example

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