Is there a way to have a Codeigniter controller return an image?

后端 未结 7 1303
隐瞒了意图╮
隐瞒了意图╮ 2021-02-08 01:59

I was wondering if there was a way for a controller to, instead of returning a string, or a view, return an image (be it JPG, PNG etc). For example, instead of ending with a $t

7条回答
  •  粉色の甜心
    2021-02-08 02:35

    If it fits your use case, simply redirecting to it is just fine. For example, tracking using images would be like:

    // Do your logic here
    
    redirect($image_path); // Or PHP's header location function
    

    No need to change headers. Your use case may not fit this, but someone might find this useful ^_^

提交回复
热议问题