Page 1 of 1
linking to a folder higher up in the hierarchy
Posted: Mon Nov 10, 2008 12:53 pm
by sumwutt
Ok, so I am trying to link to an image that is in a folder that is higher up in the hierarchy. I have set the file permissions on both the folder and the image to 0755. I have not had any problems linking to images in the same folder.
Here is the img tag I am using:
echo "<img src ='../../../../uploads/dragonBanner.jpg' style ='margin-bottom: 25px' alt ='user added banner' title ='user added banner' /><br />";
The ../'s are the correct amount, and when the page displays I get the alt content.
Any ideas would be much appreciated...
Thanks,
SuMWuTT
Re: linking to a folder higher up in the hierarchy
Posted: Mon Nov 10, 2008 2:50 pm
by requinix
Try browsing to the image itself and see what happens.
Re: linking to a folder higher up in the hierarchy
Posted: Mon Nov 10, 2008 2:59 pm
by sumwutt
Tried that but the uploads folder is above the www entry folder from the web. So I can't get to it from the browser.
Re: linking to a folder higher up in the hierarchy
Posted: Mon Nov 10, 2008 3:12 pm
by Mark Baker
sumwutt wrote:Tried that but the uploads folder is above the www entry folder from the web. So I can't get to it from the browser.
If it's outside of the web server root, then you can't access it using the img tag <img src="../img.gif"> unless you write a little script that can read outside of the web server root and use <img src="imgScript?img=../img.gif">
Re: linking to a folder higher up in the hierarchy
Posted: Mon Nov 10, 2008 3:30 pm
by Syntac
Rule of thumb: If you can't access it by typing the URL into the browser, you can't access it with an HTML tag.
In order to make a script output the image, try something like the following:
Code: Select all
$image_data = file_get_contents( "path/to/image.png" );
header( "Content-type: image/png" ); // You'll need to change this to the appropriate MIME type, of course.
echo $image_data;
Re: linking to a folder higher up in the hierarchy
Posted: Mon Nov 10, 2008 6:32 pm
by sumwutt
thank you,
I will try this, although I am not sure how to apply this to the code I am using.
sumwutt
Re: linking to a folder higher up in the hierarchy
Posted: Fri Nov 14, 2008 6:24 pm
by sumwutt
I had some trouble implementing your code syntac, but I did find a place in the hierarchy that the upload took and I could access it using my original code.
I will continue to work on the code you gave me though as I can't stand to give up on anything.
thanx for help all it was much appreciated.