2012-11-18 54 views
0

我發送很多(每秒幾個)圖像通過FTP到我的網絡服務器。問題是,我向用戶展示了收到的最後一張圖片,但有時最後一張圖片沒有完全傳輸。那麼如何在將圖像顯示給用戶之前檢查圖像是否完全傳輸。如何知道圖像是否已完全傳輸?

$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); 
       } 
      } 
     } 
+4

隨着1182代表,你一定知道,我們不能幫你沒有看到任何代碼。請告訴我們你的PHP嗎? –

+0

現在你可以回答我@MichaelBerkowski? – PachinSV

回答

9

簡單的答案是在GD中暴力破解它,看看你是否得到一個錯誤。

長(最好)答案是上傳一個CRC32校驗和列表與您的文件,並讓PHP檢查校驗和是否匹配,然後再顯示它們。如果您提供了代碼,我會提供實現細節,但是...缺少精確性,缺少準確的答案。

+0

說得好! +1! –

相關問題