I’ve created an image class to display and convert images on the site with GD library. when I want to show jpeg images without any HTML code in the site
everything will be OK because I set header(‘Content-Type: image/jpeg’).
My code is like below:
$filepath = 'path to the image file';
$info = getimagesize( $filepath );
$this->type = $info[2];
if( $this->type == IMAGETYPE_JPEG )
{
$this->image = imagecreatefromjpeg($filepath); // set the resource image
}
if( $this->type == IMAGETYPE_JPEG )
{
$type = 'image/jpeg';
}
header('Content-Type: ' . $type );
if( $this->type == IMAGETYPE_JPEG )
{
imagejpeg( $this->image );
}
This code works perfectly, but how should I show images if I want to show them inside HTML codes (ob_start did not work).
Request that script from a different file like any regular image: