Welcome Guest, Not a member yet? Register   Sign In
Preventing direct access to images... or something...?
#11

[eluser]Jim OHalloran[/eluser]
[quote author="crikey" date="1189011132"]I guess it raises the issue though of serving the public/private images as part of an HTML page (in this case the image content itself wouldn't be output, rather a link to it, as in
Code:
<img src=... />
[/quote]Once the images are outside the webroot you'll need to have a script which sends the images to the browser, which gives you the opportunity you need to do your access checks. If you used a URL like this in your image tags:
Code:
<img src="http://my-site.com/images/serve/1234">
You could create a controller called images, and include a function like this....
Code:
function serve($image_id) {
  // Do access checks here...

  // If access is allowed, figure out where the real image is from the image id...

  // Output the image...
  header('Content-Type: image/jpeg');
  echo(file_get_contents($actual_path_to_image));
}
You can use the routes.php file to make the image URL a bit shorter if you like, but that gives you the idea.

Jim.


Messages In This Thread
Preventing direct access to images... or something...? - by El Forum - 09-04-2007, 09:05 PM
Preventing direct access to images... or something...? - by El Forum - 09-04-2007, 10:31 PM
Preventing direct access to images... or something...? - by El Forum - 09-04-2007, 10:47 PM
Preventing direct access to images... or something...? - by El Forum - 09-04-2007, 10:52 PM
Preventing direct access to images... or something...? - by El Forum - 09-04-2007, 11:38 PM
Preventing direct access to images... or something...? - by El Forum - 09-05-2007, 01:20 AM
Preventing direct access to images... or something...? - by El Forum - 09-05-2007, 01:48 AM
Preventing direct access to images... or something...? - by El Forum - 09-05-2007, 02:02 AM
Preventing direct access to images... or something...? - by El Forum - 09-05-2007, 04:53 AM
Preventing direct access to images... or something...? - by El Forum - 09-05-2007, 05:52 AM
Preventing direct access to images... or something...? - by El Forum - 09-05-2007, 06:11 PM
Preventing direct access to images... or something...? - by El Forum - 09-05-2007, 07:35 PM
Preventing direct access to images... or something...? - by El Forum - 09-05-2007, 08:08 PM
Preventing direct access to images... or something...? - by El Forum - 10-16-2007, 01:45 PM



Theme © iAndrew 2016 - Forum software by © MyBB