What best practices should be followed when adjusting PHP settings for FTP via web applications?

When adjusting PHP settings for FTP via web applications, it is important to ensure that the necessary PHP functions and configurations are enabled to allow for secure and efficient file transfers. This includes enabling the FTP extension in PHP, setting appropriate permissions for file uploads, and configuring FTP settings such as host, username, and password.

// Enable FTP extension in PHP
extension=ftp.so

// Set FTP server settings
$ftp_server = "ftp.example.com";
$ftp_user = "username";
$ftp_pass = "password";

// Connect to FTP server
$conn_id = ftp_connect($ftp_server);

// Login to FTP server
$login_result = ftp_login($conn_id, $ftp_user, $ftp_pass);

// Check if connection and login were successful
if ($conn_id && $login_result) {
    echo "Connected and logged in to $ftp_server";
} else {
    echo "Failed to connect or login to $ftp_server";
}

// Close FTP connection
ftp_close($conn_id);