如何使用PHP提供图像文件?

I have a img tag as

<img src="http://######/index.php?option=com_payplans&view=cron" alt="."/>

But src is not a path of image. This url executes a php script. I want show an image intead of alternate text of broken image. I am using Google Chrome.

Got the solution by adding following code in my script

header("Content-type: image/png");
echo file_get_contents(PATH_TO_IMAGE');

So modify your PHP script to echo an image.

e.g.

header('Content-type: image/jpg');
readfile('/path/to/file.jpg');

The PHP script must return an image. How does your index.php look like?

It should be

Header("image/png");
// Dump image data here

Also try calling http://######/index.php?option=com_payplans&view=cron in a browser to see if any error occurs.

This should work if the server response is okay. It should response with a valid content type and valid binary content.

You can draw an image using gd library

read this