Reputation: 921
i want a shared folder which contains images to be accessed by html pages inside sub folders.(child folders)
Upvotes: 2
Views: 31622
Reputation: 16269
If I got it right, you have a folder with many folders inside, and inside does many folder you have html pages, and you want does pages to access the first folder...
main_folder
pic.png
pic.gif
pic.jpg
sub_folder
html_page.php
just use ../pic.png when you call the image file from the html_page.php
Was this what you where looking for ?
Upvotes: 1
Reputation: 1721
You can get the directory of the current file with the dirname funciton:
dirname(__FILE__)
If you want the parent directory you can use '..' thus:
$current_dir = dirname(__FILE__);
$parent_dir = $current_dir.'/..';
Upvotes: 0
Reputation: 17314
If you mean your html folder and images folder are siblings, you're probably looking for the ..
directory... um, thingy.
Your files look like:
/www
/html
index.php
/images
myimage.png
Write an img tag like this:
<img src="../images/myimage.png" />
Upvotes: 11
Reputation: 39763
Basically, there are two ways of linking to a resource (page/script/image/whatever):
http://www.yourserver.com/path/to/resource.jpg
http://www.yourserver.com/path/from/page.html
to http://www.yourserver.com/path/to/resource.jpg
, you use ../to/resource.jpg
So just put your images on a publicly accessibly folder, and refer to them using one of those two methods.
Or refine your question :)
Upvotes: 1