Welcome Guest, Not a member yet? Register   Sign In
Quick PHP CI question.
#1

[eluser]theknight[/eluser]
I have written the following segment of code in order to protect my images from being accessed directly.

View:

Code:
<img src='&lt;?php echo base_url(); ?&gt;index.php/Controller/getImage/obama.jpg' width="100px">

Controller:

Code:
//function to protect images from being accessed directly.
function getImage($img_id){


      //code to authenticate user goes here then...
$url = $this->data['base_url'].'system/application/images/c/thumbs/';

$filepath = $url.$img_id;

    header("Content-type: image/jpeg");
  if(file_exists($filepath)){
        $img_handle = imagecreatefromjpeg($filepath) or die("");
        ImageJpeg($img_handle);
    }



    }

Anyway, I am not having any luck. It is returning a broken image, rather then the actual image itself. Why?

All help appreciated. Thank you.


Messages In This Thread
Quick PHP CI question. - by El Forum - 07-12-2012, 08:52 AM
Quick PHP CI question. - by El Forum - 07-12-2012, 09:11 AM
Quick PHP CI question. - by El Forum - 07-12-2012, 09:46 AM



Theme © iAndrew 2016 - Forum software by © MyBB