2012-05-29 33 views
3

我檢查了很多帖子關於這個問題,但沒有什麼符合我的。非常奇怪的問題與「資源解釋爲圖像,但與MIME類型文本/ HTML傳輸」

我在測試我的項目,我得到這樣的警告或錯誤(我並不確切地知道)

Resource interpreted as Image but transferred with MIME type text/html 

一些來自同一個文件夾中的圖片的加載,但有些則不是。

THIS IS THE SITE -an上傳網站

10分鐘前這個問題是沒有,但現在不知從何處出現。

即使在我的電腦上,我測試了這個網站數百次。

而且我確定這不是一個.htaccess問題。

我能做些什麼呢?

謝謝!

回答

1

您正在構建圖像並將其發送至count.php,但您尚未更改標頭以反映適當的MIME類型。您需要更改標題以反映響應中的內容類型。

例子:

我想通過一個PHP腳本發送一個PNG文件下來,所以我需要設置的內容類型,以反映這一點:

$im = imagecreatefrompng("test.png"); 
header('Content-Type: image/png'); 
imagepng($im); 
imagedestroy($im); 
+0

我研究多,現在我知道,在IMG出現問題。 src中的javascript(我用js加載一些圖像)。那有什麼問題? – boyd

+0

@boyd您使用的圖片來源是什麼? – Sampson

+0

它是圖像的直接位置,例如:files/images/1.jpg和img.src =「files/images/1.jpg」; – boyd

1

我有同樣的問題,但在Google進行深入的搜索之後,問題解決了。此提示可能有助於您遇到同樣問題的您。 我已經擺弄Apache的httpd.conf文件。請到文件的以下部分:

</IfModule> mime_module> 
# 
# TypesConfig points to the file containing the list of mappings from 
# filename extension to MIME-type. 
# 
TypesConfig conf/mime.types 

# 
# AddType allows you to add to or override the MIME configuration 
# file specified in TypesConfig for specific file types. 
# 
#AddType application/x-gzip .tgz 
# 
# AddEncoding allows you to have certain browsers uncompress 
# information on the fly. Note: Not all browsers support this. 
# 
#AddEncoding x-compress .Z 
#AddEncoding x-gzip .gz .tgz 
# 
# If the AddEncoding directives above are commented-out, then you 
# probably should define those extensions to indicate media types: 
# 
AddType application/x-compress .Z 
AddType application/x-gzip .gz .tgz 

# 
# AddHandler allows you to map certain file extensions to "handlers": 
# actions unrelated to filetype. These can be either built into the server 
# or added with the Action directive (see below) 
# 
# To use CGI scripts outside of ScriptAliased directories: 
# (You will also need to add "ExecCGI" to the "Options" directive.) 
# 
AddHandler cgi-script .cgi 

# For type maps (negotiated resources): 
#AddHandler type-map var 

# 
# Filters allow you to process content before it is sent to the client. 
# 
# To parse .shtml files for server-side includes (SSI): 
# (You will also need to add "Includes" to the "Options" directive.) 
# 
#AddType text/html .shtml 
#AddOutputFilter INCLUDES .shtml 
AddType application/x-httpd-php .php 
AddType application/x-httpd-php .phtml 



</IfModule> 

確保添加以下AddTypes被列入上述模塊,而不鎊(#)鍵英寸請不要使用#鍵在以下任何AddTypes面前的時候,你的模塊中加入他們的方式Apache服務器將讀取它們:

AddType image/gif .gif 

AddType image/jpeg .jpeg .jpg 

AddType image/png .png 
+0

所以這隻會在我的服務器上正常工作?(因爲我修改了我的httpd.conf文件)。我怎樣才能使它在每臺服務器上工作? – boyd

相關問題