What is the difference between uploading a file and uploading a string to an FTP server using PHP?

When uploading a file to an FTP server using PHP, you need to use the `ftp_put()` function to transfer the file from your local directory to the remote server. On the other hand, when uploading a string to an FTP server, you can use the `ftp_fput()` function to write the string directly to a file on the remote server.

// Upload a file to FTP server
$localFile = 'localfile.txt';
$remoteFile = 'remotefile.txt';

$ftp_conn = ftp_connect('ftp.example.com');
$ftp_login = ftp_login($ftp_conn, 'username', 'password');

if (ftp_put($ftp_conn, $remoteFile, $localFile, FTP_ASCII)) {
    echo "File uploaded successfully.";
} else {
    echo "Error uploading file.";
}

ftp_close($ftp_conn);

// Upload a string to FTP server
$remoteFile = 'remotefile.txt';
$string = 'Hello, World!';

$ftp_conn = ftp_connect('ftp.example.com');
$ftp_login = ftp_login($ftp_conn, 'username', 'password');

$handle = fopen('php://temp', 'r+');
fwrite($handle, $string);
rewind($handle);

if (ftp_fput($ftp_conn, $remoteFile, $handle, FTP_ASCII)) {
    echo "String uploaded successfully.";
} else {
    echo "Error uploading string.";
}

ftp_close($ftp_conn);