2012-04-11 25 views
0

私はphp(codeigniter)を使って画像を作成し、ブラウザに表示する必要があります。codeigniterで作成した画像を表示

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

// class Welcome extends CI_Controller { 


    class Get_captcha extends CI_Controller { 

function __construct() 
{ 
    parent::__construct(); 
    $this->load->library('session'); 
    $this->load->library('form_validation'); 
    $this->load->helper(array('form', 'url')); 

} 

function index() 
{ 

// header('Content-Type: image/png'); 
Header("Content-type: image/png"); 
// Create the image 
$im = imagecreatetruecolor(400, 30); 

// Create some colors 
$white = imagecolorallocate($im, 255, 255, 255); 
$grey = imagecolorallocate($im, 128, 128, 128); 
$black = imagecolorallocate($im, 0, 0, 0); 
imagefilledrectangle($im, 0, 0, 399, 29, $white); 

// The text to draw 
$text = 'Testing...'; 
// Replace path by your own font path 
$font = 'verdana.ttf'; 

// Add some shadow to the text 
imagettftext($im, 20, 0, 11, 21, $grey, $font, $text); 

// Add the text 
imagettftext($im, 20, 0, 10, 20, $black, $font, $text); 

// Using imagepng() results in clearer text compared with imagejpeg() 
imagepng($im); 
imagedestroy($im); 


} 



    } 

を次のように私はそれがエラーを示すhttp://localhost/tvc/index.php/get_captchaと呼ばれるとき、私はいずれかが私を助けてください..

をクラスを得ましたか。

+1

エラーとは何ですか? – cchana

+1

404エラーが見つかりませんでしたか? –

+0

エラーは..画像に「エラー:http://localhost/tvc/index.php/get_captcha canot」と表示される可能性があります。 – ramesh

答えて

1

ほとんどの場合、エラーが見つかりません。verdana.ttfとは何かを持っている

おかげで...

+0

はいパスが正しい – ramesh

関連する問題