Are there alternative methods to upload files to an FTP server from a web page using PHP?

One alternative method to upload files to an FTP server from a web page using PHP is to use cURL to transfer the file. This can be achieved by reading the file contents and then sending it to the FTP server using cURL functions.

<?php

$ftp_server = 'ftp.example.com';
$ftp_user = 'username';
$ftp_pass = 'password';
$file_path = 'path/to/upload/file.txt';
$remote_file = 'file.txt';

$ch = curl_init();
$fp = fopen($file_path, 'r');

curl_setopt($ch, CURLOPT_URL, "ftp://$ftp_user:$ftp_pass@$ftp_server/$remote_file");
curl_setopt($ch, CURLOPT_UPLOAD, 1);
curl_setopt($ch, CURLOPT_INFILE, $fp);
curl_setopt($ch, CURLOPT_INFILESIZE, filesize($file_path));

curl_exec($ch);

curl_close($ch);
fclose($fp);

?>