What is the correct way to specify the path for uploading a file using the ftp_chdir() function in PHP?

When using the ftp_chdir() function in PHP to change the directory for uploading a file via FTP, it is important to provide the correct path to the desired directory. The path should be relative to the current working directory on the FTP server. If the path is incorrect or not properly formatted, the function may fail to change the directory, resulting in errors or the file being uploaded to the wrong location.

// Connect to FTP server
$ftp_server = 'ftp.example.com';
$ftp_user = 'username';
$ftp_pass = 'password';
$conn_id = ftp_connect($ftp_server);
ftp_login($conn_id, $ftp_user, $ftp_pass);

// Specify the directory path for uploading
$upload_dir = '/path/to/upload/directory';

// Change directory for uploading
if (ftp_chdir($conn_id, $upload_dir)) {
    echo "Changed directory successfully";
} else {
    echo "Failed to change directory";
}

// Close FTP connection
ftp_close($conn_id);