Welcome Guest, Not a member yet? Register   Sign In
Restrict direct image viewing
#4

[eluser]Lone[/eluser]
From what I can gather there are two issues you need to resolve.

1. Protect the directory they are actually in - just use a htaccess file like suggested above.

2. Output the images from a different path

For the second solution there are a few ways you achieve it depending on how strong you want to hide the images. You could save a reference to each image in the DB with a unique token eg:

Code:
ID  | file     | token
----+----------+--------------------
3   | 5353.png | gj346dagfaw4653dfd
------------------------------------
4   | 2563.png | hadfg346dafshdfhsa
------------------------------------


Create a controller called 'image' with a method called 'view' which you would have the following:

Code:
function view() {
  $token = $this->uri->segment(3);
  $path = $this->Somemodel->get_image_path($token);
  $mimetype = get_mimetype($path); // will need file_helper loaded
  ob_get_clean();
  header('Content-Type: '.$mimetype);
  ob_flush();
}

Then for people to access the image you would set a source as follows:
Code:
<img src="image/view/&lt;?=$token; ?&gt;" alt="image" />


Messages In This Thread
Restrict direct image viewing - by El Forum - 06-05-2008, 06:11 PM
Restrict direct image viewing - by El Forum - 06-06-2008, 12:28 AM
Restrict direct image viewing - by El Forum - 06-06-2008, 12:40 AM
Restrict direct image viewing - by El Forum - 06-06-2008, 01:05 AM
Restrict direct image viewing - by El Forum - 06-06-2008, 01:50 AM
Restrict direct image viewing - by El Forum - 06-06-2008, 01:14 PM
Restrict direct image viewing - by El Forum - 06-07-2008, 12:41 PM
Restrict direct image viewing - by El Forum - 06-07-2008, 06:18 PM
Restrict direct image viewing - by El Forum - 06-08-2008, 02:06 AM
Restrict direct image viewing - by El Forum - 06-09-2008, 02:17 AM
Restrict direct image viewing - by El Forum - 06-09-2008, 06:52 PM
Restrict direct image viewing - by El Forum - 06-09-2008, 08:09 PM
Restrict direct image viewing - by El Forum - 06-10-2008, 09:03 AM
Restrict direct image viewing - by El Forum - 06-10-2008, 10:58 AM



Theme © iAndrew 2016 - Forum software by © MyBB