我有问题!
我可以通过 imagecopyresampled()
获取图像并调整它的大小。
但是当我尝试使用 ftp_put()
时:期望参数 3 是有效路径。
我尝试使用:
ob_start();
imagejpeg($resource, NULL);
$resource = ob_get_contents();
没用。我不需要将图像保存到本地计算机。
最佳答案
使用 FTP protocol wrapper ,比如:
imagejpeg($resource, "ftp://user:password@example.com/dir/file.jpg");
更通用的“将内存中的内容上传到 FTP”将是:
ob_start();
imagejpeg($resource, NULL);
$contents = ob_get_contents();
file_put_contents("ftp://user:password@example.com/dir/file.jpg", $contents);
另见 Transfer in-memory data to FTP server without using intermediate file .
关于php - 如何从 URL 获取图片 -> 调整大小而不保存 -> 上传到 FTP?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30409452/