2016-12-14 120 views
-1

我收到此錯誤:PHP - 警告:和getimagesize未能打開流:HTTP請求失敗

Warning: getimagesize(http://dev.clearcaresolutions.local/viewimage.php?file=screenshot_from_2016-11-29_12-12-06.png&type=form): 
failed to open stream: HTTP request failed! HTTP/1.0 
500 Internal 
Server Error in /var/www/vhosts/dev.clearcaresolutions.local/current/modules/tasks/edit_log.php on line 845 

這是響應代碼(請不要判斷,我沒有寫這篇文章,我有與它共處:/):

$fSize = filesize($dataPath.'/'.$file); 
$fType = cFile::getMimeType($file); 

    // write the HTML headers 
    header ("X-Frame-Options: sameorigin"); 
    #header("X-Frame-Options: deny");           # on 
    header ("X-XSS-Protection: 1; mode=block");         # off 
    header ("X-Content-Type-Options: nosniff");         # on 
    // BEGIN extra headers to resolve IE caching bug (JRP 9 Feb 2003) 
    header("Pragma: ");               # on 
    header("Cache-Control: ");             # on 
    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");       # on 
    header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");    # on 
    header("Cache-Control: no-store, no-cache, must-revalidate"); //HTTP/1.1 # on 
    header("Cache-Control: post-check=0, pre-check=0", false);     # on 
    // END extra headers to resolve IE caching bug 

    header("MIME-Version: 1.0"); 
    header("Content-Description: File Transfer"); 
    header("Content-Length: {$fSize}");           # --- 
    header("Content-Type: {$fType}");           # on 
    header("Content-Transfer-Encoding: binary");        # --- 
    header("Content-disposition: {$mode}; filename={$file}");     # on 
    echo readfile($dataPath.'/'.$file); 

$ FSIZE$ F型是正確的,所以這不是問題。

這是我所說的響應:

$protocol = stripos($_SERVER['SERVER_PROTOCOL'],'https') === true ? 'https://' : 'http://'; 
(line 845) list($width, $height) = getimagesize($protocol.$_SERVER['SERVER_NAME'].$field['fieldsrc']); 

當我使用$場[ 'fieldsrc'](這看起來是這樣的:

/viewimage.php?file=screenshot_from_2016-11-29_12-12-06.png&type=form 

數據src裏面的圖片標籤,圖片顯示正常,所以我猜測迴應是正確的。有什麼想法這裏有什麼不對?

+1

'& amp;'......?這看起來不太好... – deceze

+0

是你從'edit_log.php'發佈的代碼嗎?如果是這樣,你能指出哪一行是845,這會有所幫助。 – castis

+0

Line ** 845 **是**列表($ width,$ height)= getimagesize($ protocol。$ _ SERVER ['SERVER_NAME']。$ field ['fieldsrc']); ** – Sasha

回答

0

readfile已經輸出文件的內容。刪除它前面的回聲。它應該只有

readfile($dataPath.'/'.$file); 
+0

刪除回顯,仍然得到了同樣的錯誤。 – Sasha

相關問題