473,669 Members | 2,457 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

directory paths...how does this work?

In ASP/IIS if I want to point to a folder/directory in the root as an
in include I write this...

<!--#include virtual="/menu.asp" -->

In PHP/Apache I have to do this...
<?php include "menu.php" ?> or something like this....

My problem is in asp I can reference this file from any
folder/directory. For example, if I were here.... "/admin/default.asp"
I could reference the include as is. In php I can't do this, at least
I don't know how to. Another problem is that if there are file paths
in the include itself this problem comes up again. I know I could
write this <?php include "../menu.php"?> and it would find it's way to
the file but what about the file paths in the include? This is a menu
with relative paths to images.

How can I point at a file in the root from any directory in my website
using a relative path? I know I should probably avoid an http://
reference.

Thanks!!

Jan 6 '06 #1
3 2251
On 2006-01-06, John K <ki*****@yahoo. com> wrote:
My problem is in asp I can reference this file from any
folder/directory. For example, if I were here.... "/admin/default.asp"
I could reference the include as is. In php I can't do this, at least
I don't know how to. Another problem is that if there are file paths
in the include itself this problem comes up again. I know I could
write this <?php include "../menu.php"?> and it would find it's way to
the file but what about the file paths in the include? This is a menu
with relative paths to images.


PHP has a configuration setting include_path.
Apart from setting it in php.ini you can also change it at runtime
(http://www.php.net/ini_set).
And you can manipulate it with http://www.php.net/get_include_path and
http://www.php.net/set_include_path

The only problem you might experience is that paths are separated with ; on
windows platforms and with : on unix platforms. To avoid this i suggest you take
an approach as following:

$include_paths = array('.', '..', '/var/somewhere' , get_include_pat h());
ini_set('includ e_path', implode(PATH_SE PARATOR, $include_paths) );
--
Met vriendelijke groeten,
Tim Van Wassenhove <http://timvw.madoka.be >
Jan 6 '06 #2
John K wrote:
In ASP/IIS if I want to point to a folder/directory in the root as an
in include I write this...

<!--#include virtual="/menu.asp" -->

In PHP/Apache I have to do this...
<?php include "menu.php" ?> or something like this....

My problem is in asp I can reference this file from any
folder/directory. For example, if I were here.... "/admin/default.asp"
I could reference the include as is. In php I can't do this, at least
I don't know how to. Another problem is that if there are file paths
in the include itself this problem comes up again. I know I could
write this <?php include "../menu.php"?> and it would find it's way to
the file but what about the file paths in the include? This is a menu
with relative paths to images.

How can I point at a file in the root from any directory in my website
using a relative path? I know I should probably avoid an http://
reference.

Thanks!!


Check out $_SERVER['DOCUMENT_ROOT']. It always points to the root
directory of your web site, no matter where that is.

You could, for instance, do something like:

<?php include($_SERVE R['DOCUMENT_ROOT'] . '/include/menu.php'); ?>

or similar.
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Jan 6 '06 #3
As it's turning out this entire problem "isn't" a problem on the live
server. I'm using XAMPP to develop locally and it appears this problem
is coming from there? I haven't throughly tested on the live server
yet but someone demonstrated to me that the absolute paths "do" work
there, they just don't on XAMPP. It may yet turn out to no be this
simple but we'll see.

Are there any XAMPP experts out there?

Jan 9 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1862
by: Fuzzyman | last post by:
I wish to restrict access to a program to certain directories. I also wish to prevent access to certain directories. What this means is that given a path, I need to work out if that path is in a certain directory... or in a subdirectory of that directory. (On a Linux server). The only way I can think of so far is to turn both paths into absolute paths, strip off the filename and compare... is this the most elegant way ?
2
3543
by: ngposter | last post by:
Try the following code snippet: Directory.CreateDirectory(@"C:\Folder1\"); Directory.Move(@"C:\Folder1\", @"C:\Folder2\"); Directory.Delete(@"C:\Folder2\"); After executing, a C:\Folder1 still exists! Stranger yet, place a breakpoint on "Directory.Delete(@"C:\Folder2\");" and run the code. Have Windows Explorer open in the background.
8
3383
by: nick | last post by:
I have a problem and I've been using a cheezy work around and was wondering if anyone else out there has a better solution. The problem: Let's say I have a web application appA. Locally, I set it up as C:\domains\appA. Locally, my IIS root points to C:\domains. I don't point it to C:\domains\appA since if I have an appB under C:\domains I wouldn't be able to get to it. So to access it via my browser I go to localhost/appA.
3
6808
by: KSC | last post by:
Hello, Is there a way to programmatically determine if a directory is shared and if so, what the sharename is? It seems a simple question, but I have been searching and not found the answer... Thanks in advance!
11
5788
by: comp.lang.php | last post by:
Once again, I thought my class method deleteZip() would do the trick, but it never deletes any .zip* file found in a directory: /** * Delete any latent ZIP files found in this album. This method is to be inherited by all listing classes to allow for * list-wide deletion of latent server-created ZIP files for security purposes *
15
10848
by: Sandra-24 | last post by:
Comparing file system paths as strings is very brittle. Is there a better way to test if two paths point to the same file or directory (and that will work across platforms?) Thanks, -Sandra
14
13538
by: gio | last post by:
I have a problem and the solution should works under windows and unix OS. Suppose I have a program ex.c in the directory X (so the current working directory of ex.c is X). Also suppose I have this code fragment: .... char otherpath; char cmd;
6
7543
by: titan.nyquist | last post by:
The WebBrowser control won't load a css file written in the same directory as the program. If I put an absolute path to it, it will load it. Thus, the current directory of the WebBrowser control isn't the current directory of the program. What is the current directory? I don't want to use an absolute path, since its contents are saved to disk, and that should always load the css file no matter where it and the css file exists. Titan
4
3327
by: tshad | last post by:
I have a site www.stf.com and a site www.stfstage.com (where I do all my testing). The problem is that www.stfstage.com is only internal and I need to get access from the outside (without creating a new domain). I tried to create a Virtual directory inside my stf site so that I would access it like: www.stf.com/stage/. I run as www.stfstage.com fine and have for a long time.
0
8465
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8894
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8587
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7407
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6210
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5682
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4206
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2792
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2029
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.