w3resource

PHP: ftp_cdup() function

Description

The ftp_cdup() function is used to change the current directory to the parent directory.

Version:

(PHP 4 and above)

Syntax:

ftp_cdup(ftp_stream)

Parameters:

Name Description Required /
Optional
Type
ftp_stream The link identifier of the FTP connection. Required Resource

Return value:

TRUE on success or FALSE on failure.

Value Type: Boolean

Example:

<?php
$ftp_server="192.168.0.2";
$ftp_user_name="abc123";
$ftp_user_pass="abc123";
// set up basic connection
$conn_id = ftp_connect($ftp_server);
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// change the current directory to html
ftp_chdir($conn_id, 'test');
echo ftp_pwd($conn_id); // /test
// return to the parent directory
if (ftp_cdup($conn_id)) { 
  echo "<br />cdup successful\n";
} else {
  echo "cdup not successful\n";
}
echo "<br />".ftp_pwd($conn_id); // /
ftp_close($conn_id);
?>

See also

PHP Function Reference

Previous: ftp_alloc
Next: ftp_chdir



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://www.w3resource.com/php/function-reference/ftp_cdup.php