hyeteck Posted June 23, 2007 Share Posted June 23, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/56813-display-image-above-root-directory/ Share on other sites More sharing options...
wildteen88 Posted June 23, 2007 Share Posted June 23, 2007 You could try using ../upload/ as the path, eg: <img src="../uploads/image.jpg"> ../ means go up one level higher in the directory tree. Quote Link to comment https://forums.phpfreaks.com/topic/56813-display-image-above-root-directory/#findComment-280818 Share on other sites More sharing options...
dsims Posted October 10, 2010 Share Posted October 10, 2010 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; Quote Link to comment https://forums.phpfreaks.com/topic/56813-display-image-above-root-directory/#findComment-1120773 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.