我想在控制器中显示图像。它现在显示图像。这是我试图做的。
1-硬编码相对图像路径,以便不会混淆图像
2-我把这段代码放在构造函数中,它在" parent::__construct();
"之前工作。线。但是在这一行之后它没有显示出来。
class Fileupload extends Frontend_Controller
{
function __construct()
{
//code is working here and showing image
parent::__construct();
//code below this line is not working
$this->load->model('front_end/user_model');
$dst_path = "C:\\xampp\htdocs\myweb\assets/uploads/avatar.jpg";
header('Content-Type: image/jpeg');
header('Content-Length: ' . filesize($dst_path));
readfile($dst_path,true);
die;
}
任何建议??
答案 0 :(得分:1)
像这样编写代码
<?php
class Fileupload extends Frontend_Controller
{
function __construct()
{
parent::__construct();
}
public function index() {
$this->load->model('front_end/user_model');
$dst_path = "C:\\xampp\htdocs\myweb\assets/uploads/avatar.jpg";
header('Content-Type: image/jpeg');
header('Content-Length: ' . filesize($dst_path));
readfile($dst_path,true);
}
}
&GT?; 在任何MVC框架中,默认情况下始终调用索引函数。这应该有所帮助。试着告诉
答案 1 :(得分:0)
请试试这个:
select
t.noEmploye,
t.NoProjet,
c.count
from temps t
inner join (select noProjet, noEtape, count(*) as count from temps group by noProjet, noEtape) as c
on t.noProjet = c.noProjet
order by noEmploye
或者,请阅读this了解更多示例。 :)