Pyrocms前端控制器 - 无法将图像输出到浏览器

时间:2011-10-09 10:20:41

标签: codeigniter pyrocms gd2

这是下面的代码

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);     
}
}

但是我把这个控制器称为(http:// localhost / sitename / home / testimg)。 我收到了以下错误

无法显示图像“http:// localhost / sitename / home / testimg”,因为它包含错误。

请帮助我解决这个问题,我是pyrocms的新手。

2 个答案:

答案 0 :(得分:2)

解决了问题:回信时总有一个额外的空间,我不知道为什么 - ob_clean()完成工作

public function testimg(){
    ob_clean();
    header("Content-type: image/png");
    $image = imagecreatetruecolor(200, 200);
    imagepng($image);     
}

答案 1 :(得分:0)

这与PyroCMS甚至CodeIgniter无关,你只是将图像设置错误。这是一个通用的PHP错误。

相关问题