Jump to content

display image above root directory


hyeteck

Recommended Posts

hi,

 

Is it possible to display an image that is above the root directory using php?

 

for example if i have an image in /home/user/uploads/test.jpg and lets say my root directory for my site is /home/user/public_html/

 

is it possible to display test.jpg on /home/user/public_html/index.html ?

 

i am trying to create a secure file upload script and i think not having the file be directly accessed by the public is one of the main steps.

 

Link to comment
https://forums.phpfreaks.com/topic/56813-display-image-above-root-directory/
Share on other sites

  • 3 years later...

I know this topic is old, but yes you can serve images from above the webroot,

You can use .htaccess to get the rewrite the path to the image file or you can use a file that imports the image with get i.e. http://thiswebsite.com/image.php?image='imagename"

then in the image.php file

you can include the image file with the proper header.

set the $imagePath= '/what/ever/the/path/is/';

$imagPath .= $_GET['image'];

header(<whatever header you need or setup logic to get the header from the ext>);

include_once $imagePath;

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

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.