81/5000显示由PHP的GD库使用Codeigniter创建的浏览器图像

时间:2019-10-10 00:52:40

标签: php codeigniter gd

我使用以下代码在浏览器中显示通过GD库创建的图像,我正在使用CodeIgniter。但是当我在生产服务器上运行时,不会显示该图像。 但是,在纯PHP中运行的同一脚本可以在服务器上完美运行。 Codeigniter是否阻止某些内容,我可以使用任何设置吗?

<?php
defined('BASEPATH') OR exit('No direct script access allowed');


class Tarefa_gd extends MY_Controller 
{
    function __construct()
    {
        $this->_modulo      = MODULO_APP;
        $this->_controller  = strtolower( __CLASS__ );

        $this->_verifica_usuario_logado_app();

        parent::__construct();
    }



     function color()
    {
        $my_img = imagecreate( 200, 80 );
        $background = imagecolorallocate( $my_img, 0, 0, 255 );
        $text_colour = imagecolorallocate( $my_img, 255, 255, 0 );
        $line_colour = imagecolorallocate( $my_img, 128, 255, 0 );
        imagestring( $my_img, 4, 30, 25, "thesitewizard.com", $text_colour );
        imagesetthickness ( $my_img, 5 );
        imageline( $my_img, 30, 45, 165, 45, $line_colour );

        header( "Content-type: image/png" );
        imagepng( $my_img );
        imagecolordeallocate( $line_colour );
        imagecolordeallocate( $text_colour );
        imagecolordeallocate( $background );
        imagedestroy( $my_img );
    }

}
?>

0 个答案:

没有答案