[英]How to make Internet Explorer display .PNG image if its URL is specified without .PNG extension?
For example, I wish IE
could display png image, represented by URL " http://update1.osmp.ru/logos/7642909813539583507 ": 例如,我希望
IE
可以显示以网址“ http://update1.osmp.ru/logos/7642909813539583507 ”表示的png图像:
<html>
<head>
<title>Failed to display png image that comes without .png extension in URL</title>
</head>
<body>
<img src="http://update1.osmp.ru/logos/7642909813539583507">
</body>
</html>
It doesn't work because http://update1.osmp.ru/logos/7642909813539583507 is not resolved as PNG file by IE
. 这是行不通的,因为
IE
无法将http://update1.osmp.ru/logos/7642909813539583507解析为PNG文件。 Is there any workaround, plug-in, whatever to display such a url resource in IE
using img
tag? 是否有解决方法,插件,或使用
img
标签在IE
显示此类url资源的方法?
There's no such thing as a file extension in a URL. URL中没有文件扩展名。 Just things that look like file extensions and might happen to map on to a file with one on the file system.
看起来像文件扩展名的东西,可能碰巧映射到文件上,而文件系统上只有一个。
It is the content type that determines how an HTTP resource will be handled, and if you examine that one… 内容类型决定了如何处理HTTP资源,以及是否检查了该资源……
[ david ][ david@raston ] % lynx -dump -head "http://update1.osmp.ru/logos/7642909813539583507" HTTP/1.1 200 OK Date: Wed, 07 Oct 2015 09:24:16 GMT Content-Type: text/plain
… you'll see that the server claims it is a plain text file and not a PNG image ( image/png
). …您会看到服务器声称它是纯文本文件,而不是PNG图像(
image/png
)。
You need to fix the server so it sends the correct content type. 您需要修复服务器,以便它发送正确的内容类型。
How you do this will depend on the server and any server side software you are using to generate the image. 如何执行此操作将取决于服务器以及用于生成映像的任何服务器端软件。
For instance, if you are serving up a static file which doesn't have a file extension (servers normally use the file extension on the file system to determine the content type for static files) and you are using Apache HTTPD, then you could use the ForceType
directive . 例如,如果您要提供一个没有文件扩展名的静态文件(服务器通常使用文件系统上的文件扩展名来确定静态文件的内容类型)并且您正在使用Apache HTTPD,则可以使用
ForceType
指令 。
eg in your server configuration: 例如在您的服务器配置中:
<Location /logos/>
ForceType image/png
</Location>
The problem is the Content-Type
header of your response. 问题是您的响应的
Content-Type
标头。 It is text/plain
, but it must be image/png
. 它是
text/plain
,但必须是image/png
。
The Content-type
is set by the server that return the image. Content-type
由返回图像的服务器设置。 You should have a look at your server configuration. 您应该查看服务器配置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.