ochrona obrazu w nadajniku kodu

Używam następującego kodu w moim kontrolerze:

//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)){
    echo "we are here";
        $img_handle = imagecreatefromjpeg($filepath) or die("");
    echo $img_handle;
        ImageJpeg($img_handle);
    }



    }

Moim zdaniem, aby pobrać obrazy, użyłem następującego kodu:

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

Teraz, mimo że wchodzi do kontrolera, nie wyświetla obrazu. Plik Obama znajduje się we właściwym katalogu. Nie mam pojęcia dlaczego.

questionAnswers(2)

yourAnswerToTheQuestion