Pyrocms front end controller - can't output image to the browser
here is the code code below
class Home extends Public_Controller
{
/**
* Constructor method
*`enter code here`
* @开发者_如何学运维author PyroCMS Dev Team
* @access public
* @return void
*/
public function __construct()
{
parent::__construct();
}
public function testimg(){
header("Content-type: image/png");
$image = imagecreatetruecolor(200, 200);
imagepng($image);
}
}
but when i call this controller like (http://localhost/sitename/home/testimg). i got the error below
The image "http://localhost/sitename/home/testimg" cannot be displayed because it contains errors.
Kindly help me with this issue i am new to pyrocms.
Problem Solved : there was always an extra space when echo something, i don't know why - ob_clean() does the job.
public function testimg(){
ob_clean();
header("Content-type: image/png");
$image = imagecreatetruecolor(200, 200);
imagepng($image);
}
That's nothing to do with PyroCMS or even CodeIgniter, you've just set up the image wrong. That is a generic PHP error.
精彩评论