ftp_cdup() function in PHP


The ftp_cdup() function changes the current directory to the parent directory.

Syntax

ftp_cdup(con);

Parameters

  • con − The FTP connection

Return

The ftp_cdup() function returns TRUE on success or FALSE on failure.

Example

The following is an example wherein we are updating the current directory to parent directory −

<?php
   $ftp_server="192.168.0.4";
   $ftp_user="amit";
   $ftp_pass="tywg61gh";
   $con = ftp_connect($ftp_server);
   $res = ftp_login($con, $ftp_user, $ftp_pass);
   ftp_chdir($con, 'demo');
   echo ftp_pwd($con); /
   if (ftp_cdup($con)) {
      echo "Directory changed!
";    } else {       echo "Directory change not successful!
";    }    echo ftp_pwd($con);    ftp_close($con); ?>

Samual Sam
Samual Sam

Learning faster. Every day.

Updated on: 30-Jul-2019

76 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements