我的网站拒绝提供 .png 文件
将站点从暂存环境移动到生产环境时,不会显示 .png 图像文件。当直接转到图像时,firefox报告:
图像(图像路径)无法显示,因为它包含错误。
我检查了我的apache配置中的mime.types,它包含一行对于
image/png png
有谁知道这可能是什么原因造成的?我以前从未遇到过这种情况。
When moving a site from a staging environment to a production environment, .png image files are not being shown. When going to the image directly, firefox reports:
The image (image-path) cannot be displayed, because it contains errors.
I've checked mime.types in my apache config, and it contains a line for
image/png png
does anyone know what could be causing this? I've never encountered this before.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
我解决了同样的问题,检查文件名中的大写字母。我的所有 .png 文件都有大写 .PNG 后缀。把所有的东西都变成小写并且它起作用了。
i solved the same issue checking for capital letters in the file name. all of my .png files had capital .PNG suffixes. made everything lower case and it worked.
两周后同样的问题试图解决。
在 ubuntu linux 上,问题与 sendfile 有关。基于内核的操作系统功能无法与 apache2 正常工作。
刚刚将“EnableSendfile off”添加到我的 apache2.conf 中,现在图像加载正常。
我希望有帮助。
http://ubuntuforums.org/showthread.php?t=1385583
Same problem two weeks into trying to fix it.
On ubuntu linux the problem was linked to sendfile. A kernel based os function that was not working properly with apache2.
Just added "EnableSendfile off" to my apache2.conf and images now load OK.
I hope that helps.
http://ubuntuforums.org/showthread.php?t=1385583
检查 .htaccess 文件 url 重写或任何权限/限制等。
上传任何 png 图像并尝试使用浏览器打开它png 文件的直接路径。例如 http://localhost/images/test.png (如果工作正常,则意味着您的apache 完全成功处理您的 png)
检查您是否在以前的服务器(主机)中的图像目录中创建了任何符号链接。
检查您的目录权限。
清除浏览器缓存。
检查之前主机中的 appach 虚拟主机文件 httd.conf。可能之前已经创建了一些别名或类似的东西。
httpd.conf:
...
<块引用>
让我知道这些是否有效
check .htaccess file url rewrite or any permission/restrictions etc.
upload any png image and try to open it browser using direct path to ur png file. such as http://localhost/images/test.png (if it works fine, it means your apache process your png successfully fully)
check if you have created any symbolic link your images directory in your previous server(host).
check your directory permissions.
clear your browser cache.
check your appach virtual host file httd.conf in your preivous host. may be previous there has been created some alias or something like that.
httpd.conf:
...
let me know if any of this works or not
如果您的图像是真实的:可能图像在 FTP 传输过程中被破坏(不完整或错误/非二进制传输)。从服务器下载回来并查看一下。
如果您的图像是虚拟的或脚本生成的:发布代码,以便我们看看!例如,如果在
开始标记之前有一些字符,则 PHP 中经常会发生这种情况。
If your image is a real one: maybe the image was broken during the FTP transfer (incomplete or bad/non binary transfer). Download it back from the server and have a look at it.
If your image is virtual or script generated: post the code, so we can have a look at it! This often happens with PHP if you have some chars before the
<?php
opening tag for example.不幸的是,可能有很多事情:
Could be a lot of things unfortunately:
正如配置文件注释所说
“EnableSendfile 在从网络安装的文件系统提供服务时必须关闭,或者如果您的系统对这些功能的支持被破坏。”
这对我来说是个问题。
as configuration file comments say
"EnableSendfile must be turned off when serving from networked-mounted filesystems or if support for these functions is otherwise broken on your system. "
which was the issue for me.
通过 FTP 传输时确保以二进制模式传输图像
Make sure you transfer the images in binary mode when transferring through FTP
这是相当古老的,但如果有人正在寻找显示带有“img”标签的 .png 文件问题的解决方案,我花了很长时间搜索但没有结果。我一时兴起检查了图像,它有一个 Alpha 通道。我删除了 alpha 通道,尤里卡,它起作用了。只是要检查一下您是否有类似的问题。
This is rather old, but if someone is looking for a solution to problems with displaying .png files with 'img' tags, I spent quite a while searching with no results. On a whim I checked the image and it had an alpha channel. I removed the alpha channel and eureka, it worked. Just another thing to check if you have a similar problem.