开发者

my website refuses to serve .png files

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 mi开发者_如何转开发me.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.


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.


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


  1. check .htaccess file url rewrite or any permission/restrictions etc.

  2. 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)

  3. check if you have created any symbolic link your images directory in your previous server(host).

  4. check your directory permissions.

  5. clear your browser cache.

  6. 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: ...

     <VirtualHost www.mydomain.com:80>
                 ServerAdmin hostmaster@www.mydomain.com
                 DocumentRoot /home/www/www.mydomain.com/htdocs
                 ScriptAlias /cgi-bin/ /home/www/www.mydomain.com/cgi-bin/
                 ServerName www.mydomain.com
                 Alias /images/ /home/www/www.mydomain.com/images/
                 Alias /pictures/ /home/www/www.mydomain.com/upload/
                 Alias /errors/ /home/www/www.mydomain.com/errors/
                 Alias /catalog/ /home/www/www.mydomain.com/catalog/
                 ErrorLog /home/www/www.mydomain.com/logs/error_log
                 CustomLog /home/www/www.mydomain.com/logs/access_log
                 ScriptLog /home/www/www.mydomain.com/logs/script_log
                 ErrorDocument 403 /errors/403.html
                 ErrorDocument 404 /errors/404.html
                 ErrorDocument 500 /errors/500.html
         </VirtualHost>
    

let me know if any of this works or not


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:

  • Check the file permissions on the file, and ensure that apache can read them
  • Is this an 'actual' file, or is it coming from a DB or similar? If it's coming from a DB or Code investigate the actual string to be sure that content is being generated properly. If there are errors, they would ruin the output of the image
  • The file could actually be corrupt (try a re-upload)


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.


Make sure you transfer the images in binary mode when transferring through FTP

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜