Example 1 — Go Up One Folder
Enter a sub folder and then move back up with ftp_cdup(). The host and login are placeholders.
<?php
$ftp = ftp_connect("ftp.example.com");
ftp_login($ftp, "demo_user", "demo_pass");
ftp_chdir($ftp, "/public_html/images");
echo "Now in: ", ftp_pwd($ftp), PHP_EOL;
ftp_cdup($ftp);
echo "After cdup: ", ftp_pwd($ftp), PHP_EOL;
ftp_close($ftp); How It Works
- ftp_chdir() moves into the images folder.
- ftp_pwd() prints the current directory path.
- ftp_cdup() moves up one level to public_html.
- ftp_pwd() confirms the new location.

