3

我检查了很多关于这个问题的帖子,但没有与我的匹配。

我正在测试我的项目并收到此警告或错误(我不完全知道)

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

来自同一文件夹的一些图像已加载,但有些则没有。

这是网站- 一个上传网站

10 分钟前还没有这个问题,但现在它不知从何而来。

即使在我测试这个网站数百次的电脑上。

而且我确定这不是 .htaccess 问题。

我能做些什么呢?

谢谢!

4

2 回答 2

1

您正在构建图像并将其发送到 through count.php,但您没有更改标题以反映适当的 mime 类型。您需要更改标头以反映响应本身中的内容类型。

例子:

我想通过 PHP 脚本发送一个 PNG 文件,所以我需要设置 content-type 来反映这一点:

$im = imagecreatefrompng("test.png");
header('Content-Type: image/png');
imagepng($im);
imagedestroy($im);
于 2012-05-29T22:47:09.663 回答
1

我有同样的问题,但在我在谷歌中进行了深入搜索后,问题得到了解决。这个技巧可能对你们中的一些有同样问题的人有所帮助。我摆弄了 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>

确保在没有 POUND(#)KEY 的上述模块中添加以下 AddTypes。当您将它们添加到模块中时,请不要在以下任何 AddTypes 前面使用 # 键,这样 Apache 服务器会读取它们:

AddType image/gif .gif

AddType image/jpeg .jpeg .jpg

AddType image/png .png
于 2013-07-17T14:45:07.507 回答