简体   繁体   English

PHP GD库图像对某些用户不显示

[英]PHP GD Library Images Not Showing For Some Users

I run a virtual pet website and we use the PHP GD Library to produce our Avatars and Pets. 我经营着一个虚拟宠物网站,我们使用PHP GD库来生产我们的头像和宠物。 We have over a thousand users so far, and out of that only 3 users have had this issue. 到目前为止,我们已有1000多个用户,其中只有3个用户遇到了此问题。 For each user though, it's the exact same issue. 但是对于每个用户来说,这都是完全相同的问题。

Here is a screenshot of what these users see. 这是这些用户看到的屏幕截图

The majority of the images just show the "Broken Link" icon, but every once in awhile it starts to build the image and stops before finishing. 大多数图像仅显示“ Broken Link”图标,但偶尔会开始构建图像,并在完成前停止。

These are my attempts at fixing it: 这些是我修复它的尝试:

  • Removed everything from the code other than taking an image and printing it out. 从代码中删除了所有内容,除了拍摄图像并打印出来。
  • Placed the code on an entirely different Server by a different Host 通过不同的主机将代码放置在完全不同的服务器上
  • Removed the Site from Cloudflare DNS servers to see if Cloudflare was causing it 从Cloudflare DNS服务器中删除了该站点,以查看是否是Cloudflare造成的
  • Used JPEG images instead of PNGs 使用JPEG图像代替PNG

This is the information I have gathered thus far from these users: 到目前为止,我是从这些用户那里收集的信息:

  • Viewing our site through a proxy allows the images to load 通过代理查看我们的网站可以加载图像
  • Using a laptop from the same internet connection loaded the images successfully 使用来自同一Internet连接的便携式计算机成功加载图像
  • Browsers either just output the broken link or say that the image contains errors and cannot be displayed. 浏览器要么只是输出断开的链接,要么说图像包含错误并且无法显示。

And lastly, here is the code of the simple test image page I am using: 最后,这是我正在使用的简单测试图像页面的代码:

<?
$finalimage = imagecreatetruecolor(500,500);
$file = 'http://www.somesite.com/picture.jpg';
$layers = imagecreatefromjpeg($file);
imagecopy($finalimage, $layers, 0, 0, 0, 0, 500, 500);
imagedestroy($layers);

header("Content-type: image/jpeg");
imagejpeg($finalimage);
imagedestroy($finalimage);
?>

You have forgot the imagedestroy($finalimage); 您忘记了imagedestroy($finalimage); at the end, but I don't know if it will solve your problem 最后,但我不知道它是否可以解决您的问题

The issue for our users was using the Kaspersky anti-virus. 我们用户遇到的问题是使用卡巴斯基反病毒软件。 They had to add our URL to the list of trusted sites under web security. 他们必须将我们的URL添加到Web安全下的受信任站点列表中。 After doing so, all images loaded fine. 这样做之后,所有图像都可以正常加载。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM