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
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;

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.