How can the PHP documentation for ftp_put be utilized effectively in customizing file names during upload?

When uploading files using ftp_put in PHP, the documentation does not provide a direct way to customize the file names during upload. However, you can achieve this by renaming the file before uploading it using ftp_put. This can be done by using the rename function in PHP to change the file name before uploading it via FTP.

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

// Rename file before uploading
$localFile = 'local_file.txt';
$remoteFile = 'custom_file_name.txt';
rename($localFile, $remoteFile);

// Upload renamed file
ftp_put($conn, $remoteFile, $localFile, FTP_BINARY);

// Close FTP connection
ftp_close($conn);