Answer by Mitchell McKenna for Restrict Image Access Codeigniter

September 30 2010, 4:25am

You can always use PHP to stream the image from a hidden path after you authenticated the user. Create a controller called getimage.php which you call like:

<img src="getimage?imagename.jpg" />

Then in the controller:

<?php class Getimage extends Controller{ function index(){ //code to authenticate user goes here then... header("Content-type: image/jpeg"); if(file_exists(hiddenpath.$_GET['imgid'])){ $img_handle = imagecreatefromjpeg(hiddenpath.$_GET['imgid'] ) or die(""); ImageJpeg($img_handle); } } } ?>