简体   繁体   中英

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. We have over a thousand users so far, and out of that only 3 users have had this issue. 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.

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
  • Used JPEG images instead of PNGs

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
  • 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); 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. After doing so, all images loaded fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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