View Full Version : File Paths
dudeking
August 28th, 2006, 08:22 PM
Right not sure if this is possible...but...If I have a folder with my index in, then a folder with pictures, flash, css, scripts, and other pages in that folder.
So if I need to put a picture in the index easy 'images/picture.gif' but say I have a folder called contact with an index in, and I want to add a picture, script or css at the moment I have to do http://dudeking.co.uk/images/picture.gif.
But when I'm editing offline I would have to change all that to C:\...etc...
And If Im trying somthing new I will make it in www.dudeking.co.uk/beta so all my images will be http://dudeking.co.uk/beta/images/picture.gif but then if I want to move it to use as my propa site I have go go round all the scripts, pages and css removing /beta!!!
There must be somthing to make this simple?!!
degsy
August 28th, 2006, 08:37 PM
You can set your site to use relative paths.
If you have an images folder in the webroot
index.htm
-- images
-- -- image.jpg
-- folder
-- -- page.htm
You can use a relative path
<img src="images/image.jpg"
If you use this path in page.htm then the link will be broken because there is no path of folder/images/image.jpg
What you can do is setup a path from the webroot
<img src="/images/image.jpg"
In this case where ever you html file is located it will always reference the correct image file path.
For other custom folder structures you could use relative paths
index.htm
-- images
-- -- image.jpg
<img src="images/image.jpg"
-- beta
-- -- index.htm
-- -- -- images
-- -- -- -- image.jpg
If you used the same path then becasue it is relative then the absolute path would resolve to
/beta/images/image.jpg
dudeking
August 28th, 2006, 10:10 PM
Thanks Degsy!
Does this work with CSS?
#head{
background-image:/beta/images/head.gif;
background-color:#9C684C;
background-repeat:no-repeat;
background-position:left;
height:80px;
padding:3px;
}
Not working....
dudeking
August 28th, 2006, 10:29 PM
url()
FrEaKmAn
August 29th, 2006, 12:35 AM
#head{
background-image: url(../beta/images/head.gif);
background-color:#9C684C;
background-repeat:no-repeat;
background-position:left;
height:80px;
padding:3px;
}
I use ../ if I want to go one folder back like:
we have folder1 and folder2. In one we have index.htm and in other picture.gif. So I write into index.htm:
<img src="../folder2/picture.gif">
or with css:
background-image: url(../folder2/picture.gif);
Buzz
August 29th, 2006, 12:58 AM
Also a side note.. if you are using php or asp includes for a header and footer and are including these in pages that are within other directories (a la include(../header.php) then you should use absolute paths in the includes.
dudeking
August 29th, 2006, 10:04 AM
Last time I asked about Include some one said it was for local files only.
So include 'http://url.com/page.htm'; woudnt work but include 'page.htm'; would.
So are you saying that I have to do somthing like include '../pages/page.htm';
Buzz
August 29th, 2006, 05:11 PM
Yes, includes only work with relative links so you can do an include('../../head.php') but not include('http://www.blah.com/head.php');
dudeking
August 29th, 2006, 05:17 PM
Okay, Thanks Scott :)