I found this function useful when uploading a file through FTP. One of the files I was uploading was input from a textarea on the previous page, so really there was no "file" to upload, this solved the problem nicely:
<?php
$fSetup = tmpfile();
fwrite($fSetup,$setup);
fseek($fSetup,0);
if (!ftp_fput($ftp,"inc/setup.inc",$fSetup,FTP_ASCII)) {
echo "<br /><i>Setup file NOT inserted</i><br /><br />";
}
fclose($fSetup);
?>
The $setup variable is the contents of the textarea.
And I'm not sure if you need the fseek($temp,0); in there either, just leave it unless you know it doesn't effect it.