PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, October 11, 2022

[FIXED] How to display errors while trying to display images in php?

 October 11, 2022     gd, jpeg, php     No comments   

Issue

I'm using php gd library to generate image/jpeg.

I'm getting the error message:

image xyz.php cannot be displayed because it contains errors

How can I get the specific error?


Solution

  1. If you want to log the errors in image files (binary files), you shouldn't just print them, but instead - log them to external file.

When you are outputting the image to browser, there should be no output before and neither ater.

Comment out the line where you print image (imagejpeg()), and there should be no output. If there is, you have a problem.

Side note: And make sure you are not doing the mistake of outputing the image into the HTML document directly. You have to make separate PHP file for image, and then link it into document like this:

<img src="image.php" alt="" />


Answered By - Rok Kralj
Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing