ftp_pasv() function in PHP


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

Syntax

ftp_pasv(con, pasv)

Parameters

  • con − The FTP connection

  • pasv − Specifies the passive mode. The following are the possible values −

    • TRUE (passive mode on)

    • FALSE (passive mode off)

Return

The ftp_pasv() function returns TRUE on success or FALSE on failure

Example

The following is an example −

<?php
   $ftp_server="192.168.0.4";
   $ftp_user="tim";
   $ftp_pass="wthbn#@121";
   $con = ftp_connect($ftp_server) or die("Could not connect to $ftp_server");
   $login = ftp_login($con, $ftp_user, $ftp_pass);
   ftp_pasv($con, true);
   $local_file = "localfile.txt";
   $my_serverfile = "serverfile.txt";
   if (ftp_put($ftp_conn, $my_serverfile, $local_file, FTP_ASCII)){
      echo "File uploaded!";
   } else {
      echo "Error in uploading the file!";
   }
   // close
   ftp_close($con);
?>

karthikeya Boyini
karthikeya Boyini

I love programming (: That's all I know

Updated on: 30-Jul-2019

58 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements