PHP ftp_pasv() function

Definition and Usage

The ftp_pasv() function sets the passive mode to on or off.

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

Syntax

ftp_pasv(ftp_connection,mode)
Parameters Description
ftp_connection Required. Specifies the FTP connection to use (the 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, it opens the passive mode transfer (PASV MODE), otherwise, if the parameter mode If false, it turns off the passive transfer mode. In passive mode, data transfer is initiated by the client, not by the server.

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

Mfano

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