For directly inserting content into a file on an FTP host, you could also create a string stream wich streams directly to the ftp_fput function.
This should create less overhead than first writing to any temp directories locally before streaming, as suggested here.
<?php
$string = "Your content goes here";
$stream = fopen('data://text/plain,' . $string,'r');
ftp_fput($this->connection,$pathTo,$stream, FTP_BINARY);
?>