如何从网址获取图片 - >调整大小而不保存 - >上传到FTP?

时间:2015-05-23 06:03:53

标签: php ftp

我有问题!

我可以通过imagecopyresampled()获取图像并调整其大小。

但是当我尝试使用ftp_put()时:期望参数3是一个有效的路径。

我尝试使用:

ob_start();
imagejpeg($resource, NULL);
$resource = ob_get_contents();

没有用。我不需要将图像保存到本地计算机。

1 个答案:

答案 0 :(得分:2)

使用FTP protocol wrapper,例如:

container_commands:

更通用的"将内存内容上传到FTP"将是:

imagejpeg($resource, "ftp://user:password@example.com/dir/file.jpg");

另见Transfer in-memory data to FTP server without using intermediate file