2015-04-25 56 views
0

因此,在here(位於頁面底部),您可以在左下角看到(僅在使用chrome時)破碎的圖像。僅在Chrome上損壞圖片

事實證明,直接訪問它的作品。 Chrome控制檯也會爲圖像提供404錯誤。

我正在使用php文件來提供該圖像。我得到了顯示參數,並使用readfile來提供該圖像。 (代碼工作,如在其他瀏覽器中看到的或直接訪問它)

我不知道什麼是與鉻的交易。

任何幫助,將不勝感激!

我使用wordpress作爲基礎,我使用下面的php文件來過濾用戶ID能夠看到某些圖像。

對不起,如果代碼是凌亂的。我還在學習!

<?php 

define('WP_USE_THEMES', false); 
require('./wp-blog-header.php'); 

$current_user = wp_get_current_user(); 
$current_user_id = $current_user->ID; 

//save idlength to compare 

$idLength=strlen($current_user_id); 

//check for arg 
if (isset($_GET['show'])) { 

    $img="../Subidas_cliente/{$_GET['show']}"; 

    //check whether file exists 
    if (file_exists($img)){ 

     //admin ids always get image 
     if($current_user_id==2||$current_user_id==10||$current_user_id==12||$current_user_id==13){ 
      readfile($img); 
     } 

     else{ 

      //compare ids from image and requester 
      $tmp=substr($img,0,$idLength); 
      $r=strcmp($tmp, $current_user_id); 


      if ($r==0){ 

       $mime_type = mime_content_type($img); 
       header('Content-Type: '.$mime_type); 

       //readfile if ids are equal 
       readfile($img); 

      //exit if different (return image for testing purposes) 
      }else{ 
       header('Content-Type: image/jpeg'); 
       readfile('../Subidas_cliente/default.jpg'); 
      } 
     } 

    }else { 
     header('Content-Type: image/jpeg'); 
     readfile('../Subidas_cliente/default.jpg'); 
    } 
}else{ 
    header('Content-Type: image/jpeg'); 
    readfile('../Subidas_cliente/default.jpg'); 
} 

?> 
+0

我也可以在Firefox上看到破碎的圖像。 - http://siodental.com/img.php?show=2_1330_A1.jpg - 'GET /img.php?show=2_1330_A1.jpg HTTP/1.1'-響應:'HTTP/1.1 404 Not Found' –

+0

鏈接是破碎:http://siodental.com/img.php?show=2_1330_A1.jpg。不依賴於瀏覽器。 –

+0

發佈正在生成映像的php代碼,以便我們可以進一步幫助您。 –

回答

0

原來加載wordpress的功能很麻煩(和buggy)。我最終通過會話(session_start和$ _SESSION [''])變量傳遞了ID,並解決了所有問題。