Php 如何知道图像是否已完全传输?

Php 如何知道图像是否已完全传输?,php,Php,我正在通过FTP向我的web服务器发送每秒几张的图像。问题是,我正在向用户显示接收到的最后一张图像,但有时最后一张图像没有完全传输。因此,在向用户显示图像之前,如何检查图像是否已完全传输 $directory = dir($path); while (false !== ($entry = $directory->read())) { $filepath = "{$path}/{$entry}"; // could do

我正在通过FTP向我的web服务器发送每秒几张的图像。问题是,我正在向用户显示接收到的最后一张图像,但有时最后一张图像没有完全传输。因此,在向用户显示图像之前,如何检查图像是否已完全传输

$directory = dir($path);
        while (false !== ($entry = $directory->read())) {

            $filepath = "{$path}/{$entry}";

            // could do also other checks than just checking whether the entry is a file
            $imageFormats = array(IMAGETYPE_JPEG);

            if (is_file($filepath) && filectime($filepath) > $latest_ctime)
            {
                if(in_array(exif_imagetype($filepath), $imageFormats) && $imageResource = imagecreatefromjpeg($filepath))
                {
                    $latest_filename = $entry;
                    $latest_ctime = filectime($filepath);
                }
            }
        }

简单的答案是在GD中强行打开它,看看是否有错误

一个长而可取的答案是将CRC32校验和列表与您的文件一起上传,并在显示它们之前让PHP检查校验和是否匹配


如果您提供代码,我会提供实现细节,但是。。。缺少精确性,缺少精确的答案。

对于1182 rep,您肯定知道我们无法在没有看到任何代码的情况下帮助您。请给我们看看你的PHP?现在你可以回答我@MichaelBerkowski?