Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Secure a folder containing images, and use code to acces them!!!

Status
Not open for further replies.

davejam

Technical User
Jan 6, 2004
313
GB
Hi all,

something i've been puzzling on for a while, i want to password protect a folder as i don't want the world to be able to browse it (as there will be family baby photos stored in there).

But i want to have a single login to my php website for each person... ie, brother has own login, sister has own login etc etc

and then be able to include within code photos from that folder... but using a standard coded username and password.... this way i don't have to keep adding users to the folder to get access... although i don't know how to do this one either... but less worried about that!!!

anyone have any ideas about folder security and getting access to it via php pages....

any hints, tips or pointers greatly appreciated,

cheers

davejam
 
Hi

I think you want to :
[ol]
[li]deny access to the image/ directory[/li]
[li]put this script outside the image/ directory
Code:
<?php
header("Content-type: image/jpeg");
readfile("image/$_GET[image].jpg");
?>
[/li]
[li]access "/image/baby.jpg" with [navy][ignore][/ignore][/navy][/li]
[/ol]
Of course the simple solution would be to just set up your web server and do no programming. But probably I do not fully understand your idea.

Feherke.
 
That is basically what you do. In real (non-innocent) life, sanitize the image parameter first. Otherwise, everyone can download your php code to see where the vulnerabilities are:

Code:
[URL unfurl="true"]http://example.com/show.php?image=../htdocs/index.php[/URL]

You could make this as secure as you want. You could store the images or their paths in a database, with info about who is entitled to see them.

+++ Despite being wrong in every important aspect, that is a very good analogy +++
Hex (in Darwin's Watch)
 
Have you looked at Gallery2 - it is intended for exactly this soort of application
 
it is purely for a personal family thing, which is why i'd prefer to code the lot, then i'm 100% sure on the security, also lets me show off somewhat!!!! (also gives real satisfaction when everyones using your site!!!)

I will look into your suggestions over the weekend as i kinda said i'd do this at my neices christening, she's nearly one now!!!!

oooh, just thought, this might sound a little dodgy... its not i assure you!!! i want to write this to stop family pics getting out there on the web..... so its absolutely the opposite.

I do plan to hold all images within a secured folder and use a table to reference the name and location of these... the site will be secure 100% and then with extra checks i normally throw in which cost about a milli-second so i'm not so worried about time and access!!!

as i say, our family seems to have speradically located itself round europe so just finding a nice base to keep in touch!!!

Cheers for all the help

davejam
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top