PHP - 将图像资源上传到FTP

I'm trying to resize image and upload it to FTP server without saving it on local disc but I didn't find any method how to do that. Function ftp_fput obviously doesn't TAKE image resource as argument.

I'm trying to do this:

imagecopyresampled($canvas, $image, 0, 0, 0, 0, $width, $height, $oldWidth, $oldHeight);

ob_start();
imagejpeg($canvas);
$stream = ob_get_clean();

// ftp_->fput(imagecreatefromstring($stream));
ftp_->fput($stream);

Any help?

PHP doesn't have a function to write a string through ftp. You would have to write the file to disk and send it or you can use the php://memory or php://temp wrapper to write the data to memory and pass that to ftp_fput. There is a comment on the ftp_put manual page that has a simple function that flushes to a temp file.

http://www.php.net/manual/en/function.ftp-put.php#83260

There are a few comments on the ftp_fput manual page that cover this as well.