My site uses bookmarklets to gather data from external sites, kinda like Pinterest. I’m concerned about security and want to move the images the bookmarklet gathers from the doc root up one level. My script has some hefty security checks in place, but I want to add this as a last line of defense.
How do I access my images within my script? Obviously using ../userimages/id/image.jpg wont work. I’m using Apache.
Thanks!
Proxy the image
You would use a proxy script to feed the images through like the following example:
This example is from the PHP manuals
fpassthru()page. You would save this script somewhere in your servers document root/httpdocs folder.“Spoofing” the URL to the image
The easiest way to give the PHP file the appearance of being an image file to a user/browser is to use Apaches
mod_rewrite. Usually I use a URL structure something like this:Where
image-idis the unique identifier for that particular image. This way the file has the correct extensions of an image instead of.php.