In what scenarios would it be recommended to use FTP functions instead of move_uploaded_file for file uploads in PHP?

FTP functions would be recommended for file uploads in PHP when you need to upload files to a remote server or when you have limited server resources for handling file uploads. Using FTP functions allows for more control over the upload process and can be useful for transferring large files or multiple files at once.

// Example of using FTP functions for file upload in PHP

$ftp_server = "ftp.example.com";
$ftp_username = "username";
$ftp_password = "password";
$local_file = "local_file.txt";
$remote_file = "remote_file.txt";

// connect to FTP server
$ftp_conn = ftp_connect($ftp_server);
$login = ftp_login($ftp_conn, $ftp_username, $ftp_password);

// upload file
if (ftp_put($ftp_conn, $remote_file, $local_file, FTP_ASCII)) {
    echo "File uploaded successfully.";
} else {
    echo "Error uploading file.";
}

// close connection
ftp_close($ftp_conn);