I have some PHP code that successfully exports a MySQL table to a CSV file.
I would like to add to that code, so instead of saving locally the CSL file is exported
If you have ftp:// URL wrappers enabled, just open the file directly on FTP server:
$fp = fopen('ftp://username:password@ftp.example.com/path/to/somefile', 'w');
If you do not have the wrapers enabled, see: Creating and uploading a file in PHP to an FTP server without saving locally