View Full Version : How do I display images with the include function?
06-27-2010, 12:58 AM
I am trying to display an image via php include function outside of the root folder of where the php code is.
The code is:
The page with this is in /home/rootkbc1/public_html/mujak/home.php
So I am trying to get out of the "mujak" directory & into the halo2us directory.
This code seems to be display a bunch of machine code, meaning its displaying the file but does not know how to interpret it.
Something with header function~? Just read on it, don't know if this has anything to do with it.
06-27-2010, 02:53 AM
You are aware that an image cannot actually be displayed with PHP?
If your intent is to serve it, then yes just push a content type for the image. This script would then become the source for your img tag. This is a waste though since the include is just an image with no dynamic data, so just use the png for your img src instead.
06-27-2010, 06:11 AM
06-27-2010, 06:34 AM
Okay well, what is a good way to display an image outside of the root with php~???
06-27-2010, 07:11 AM
You don't display images with PHP... if you're building a webpage, you display images with HTML. So if you mean how do you display images outside the website's directory, you can't. As with any website, you can only display images accessible by the web.
06-27-2010, 07:47 AM
Are you serious~~!!! I was sure there was something you could use to access an image in a different directory outside its own.
06-27-2010, 08:09 AM
Now, with HTML, if the image is in another folder that is also accessible to the web (a different domain, a different subdomain, a subfolder), you can access it, like other images on the web. If its not, you can't.
Now, you could write a PHP script that reads an image, and generates a temporary file in the websites folder. But that would basically be putting an image into the websites folder and linking to it.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.