我有一个 cakephp 应用程序。我知道我的应用程序使用 default.ctp 作为其布局。在默认布局中,我的标题设置为 html/text。我想将标题类型更改为 image/png。我应该在哪里更改它?请有人帮助我
代码:
$this->layout=NULL;
$this->autoRender=false;
$this->RequestHandler->respondAs('image/jpg');
View Coding :(index.ctp)
<?php
session_start();
$text = rand(10000,99999);
$_SESSION["vercode"] = $text;
$height = 25;
$width = 65;
$image_p = imagecreate($width, $height);
$black = imagecolorallocate($image_p, 0, 0, 0);
$white = imagecolorallocate($image_p, 255, 255, 255);
$font_size = 14;
imagestring($image_p, $font_size, 5, 5, $text, $white);
imagejpeg($image_p, null, 80);
?>
Controller coding :
public function index()
{
$this->layout=false;
$this->response->type('png');
}
注意:CakePHP 版本 2.3.0