2012-05-29 20 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

相关问题