mikehart
-
Posts
1 -
Joined
-
Last visited
Never
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.
accessing files ONLY from php scripts (not from URL)
in Apache HTTP Server
Posted
I was interested in the same thing. I want to be able to restrict the access to a .jpg file so that only an authorized user can get to it. Using:
print("<img src="$imgFolder".$_GET["img"]."">");
}
just means that he the user doesn't need to enter the right folder, but he needs to have access to that folder.
I have found a workaround, by reading the file into php and doing something like:
<img src ="getimage.php?image=filename">
getimage.php checks to see if the user has the right access via my authorization code and then I do
readfile($filename);
The problem is that I think this might be a little slow, particularly if there are a lot of files. Also, the users can't cache the file in the browser - the next time they visit the page, they need to load the images all over again.
Does anyone have other ideas, as to how I could limit access to the files using another method?
Thanks