如何通过FTP上传生成的图像而不在本地保存

时间:2015-12-31 19:48:31

标签: php image ftp

我已成功在.jpg文件上覆盖.png文件。问题是,我需要将此文件FTP到另一台服务器,最好不要在本地保存。我已经用PHP查看了临时文件,但无法理解它。

具体来说,我正在向函数抛出一些变量。该函数从数据库中找到PNG文件的正确路径,将其放在JPEG文件中,从给定的路径开始。组合的图像需要上传到场外服务器...这是我的编码经验让我失望的地方。如果我将这个新图像写入临时文件,如何将其路径传递回上传,而不是图像本身。

    $overlayFilePath = '../overlays/'.$row["Overlay1"];

    $png = imagecreatefrompng($overlayFilePath);
    $jpeg = imagecreatefromjpeg($local_file);

    list($width, $height) = getimagesize($local_file);
    list($newwidth, $newheight) = getimagesize($overlayFilePath);
    $out = imagecreatetruecolor($newwidth, $newheight);
    imagecopyresampled($out, $jpeg, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
    imagecopyresampled($out, $png, 0, 0, 0, 0, $newwidth, $newheight, $newwidth, $newheight);
    $combinedImage = imagejpeg($out, NULL, 100);
    imagedestroy($out);

    return $combinedImage; // this is the issue. I need to return an address to the image, but I do not want to have thousands of images being saved locally on this server.

    $conn->close();
}
?>

0 个答案:

没有答案
相关问题