| |||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | #1 (permalink) |
| NamePros Member | PHP includes refererencing files from different directory Ok, here's the deallio. I've got several domains, some of them reference the same files. For example's sake, we'll call the current directory I'm working in "current." The directory structure has all the domains on the same level, so I use for instance, the same footer file in each domain. Just say to keep things simple in this case that Util is a domain on the same level as all the others. So, I've just been referencing it with for instance Code: include "../../Util/public_html/footer.html"; For instance I have a file called "navHeaders.html" that calls a few images inside of it. These images are in the same dir as navHeaders, the Util dir. So I have Code: include "../../Util/public_html/navHeaders.html"; Thanks in advance. |
| |
| | #2 (permalink) | ||
| Senior Member | Quote:
Quote:
| ||
| |
| | #3 (permalink) | |
| NamePros Member | Quote:
The navHeaders.html file, as well as the image.jpg file are both in Util/public_html. But when I include navHeaders.html from a dir called, say, "CurrentDir" I'll get an error that CurrentDir/image.jpg cannot be found. It should be also noted, not sure if I mentioned it in my original post, that the examples we're using of Util and CurrentDir are actually domains, not just directories, but in my ftp client they're handled the same as directories, and all of the domains are on the same level in the hierarchy. | |
| |
| | #4 (permalink) | |
| Senior Member | Quote:
You would have to change the path of your image(s) in your html. The easiest way would probably be to just use the full url to your images in the html rather than the relative path. | |
| |
| | #5 (permalink) | |
| NamePros Member | Quote:
Is that ok to do, will it slow down the page loading or anything like that? | |
| |
| | #6 (permalink) |
| Senior Member | dont use the full url edit you build your pages do this say you have an image called dave.gif and you want to insert it use this code <img src="/images/some/other/path" height=blah width=blah> so if your file is being included in /dave/1/3/qwetty/ or /index.html it will always work it works because the first slash inside the / tells the browsers to request files from the root directory so it doesnt matter where you place images. |
| |
| | #7 (permalink) | |
| Senior Member | Quote:
What adam_uk suggested would also work if you had a copy of whatever images/files you needed in each domains public_html directory. Because like he said, it will always request the files from the root directory. But the problem is it will be the root directory of that particular domain so you would need a copy of the images in each domains public_html directory. If you only wanted to have one set of images in just one of the domains public_html directories or somewhere else, the easiest way would probably be to use the full url which is why I suggested that way. | |
| |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Tutorial: Getting started with PHP (The Basics) | deadserious | Webmaster Tutorials | 60 | 11-17-2007 11:35 AM |
| HOWTO: Install the Apache Web Server, Perl, PHP, and MySQL on Windows | deadserious | Webmaster Tutorials | 96 | 05-27-2007 01:24 PM |
| Googlism - What does google think of you? | deadserious | The Break Room | 55 | 12-15-2005 09:09 AM |
| Tutorial: How to Install Apache2 MySQL and PHP on Windows | deadserious | Webmaster Tutorials | 35 | 09-21-2005 09:46 PM |