When using the FTP or FTPS protocols, this function sends the CDUP
command to the server. This command is a special case of the CWD
(Change Working Directory) command, and is included to simplify
transferring between directory trees on those operating systems which
have different syntaxes for naming the parent directory. The current
user must have the appropriate permission to access the parent
directory. On some systems, the user may be restricted to a specific
directory tree (for example, through a chroot environment) or server
configuration may prohibit navigating above a certain level. In these
cases, the command may succeed without changing the current directory,
or fail depending on the server implementation.
When using the SFTP protocol, there is no direct equivalent to the
CDUP command. SFTP operates on fully qualified paths rather than
maintaining a persistent current working directory on the server. To
provide consistent behavior across protocols, this method simulates
the command by normalizing the current path to its parent directory
and storing it internally.
Because this behavior is implemented client-side, changing the
working directory in an SFTP session does not affect the server state
and is only meaningful within the context of the current connection.
If the session is restricted to a specific directory (such as a chroot
environment), attempting to navigate to a parent directory above that
location will typically result in the path remaining unchanged.
Additionally, permission-related errors may not be detected when this
method is called. Instead, they may occur later when attempting to
enumerate the directory or perform file operations within it.