472,782 Members | 1,280 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,782 software developers and data experts.

including files - paths

If I'm working on a project, I'll usually create a folder to contain all
the project files before uploading this to the root of the production
server. The trouble is that if I do:
include('/myfile.php')
this looks at the root of local host, as it should and not at the root
of the working directory. It means that if I want to use absolute
links, I have to change them before I upload.

Or am I missing something blindingly obvious?

I'm pretty sure this has been done before (FAQ entry material?), but not
for a while. :-)
--
Geoff Berrow 0110001001101100010000000110
001101101011011001000110111101100111001011
100110001101101111001011100111010101101011
Jul 17 '05 #1
3 1366
Geoff Berrow wrote:
If I'm working on a project, I'll usually create a folder to contain
all the project files before uploading this to the root of the
production server. The trouble is that if I do:
include('/myfile.php') this looks at the root of local host, as it
should and not at the root of the working directory. It means that
if I want to use absolute links, I have to change them before I
upload.
Change or extend your local configuration so that it reflects the
configuration at the remote server.

An easy way is creating a virtual host on your local box with a
documentroot pointing to the wannabe /...
Or am I missing something blindingly obvious?

No, I don't think so

Hans

--
"He who asks a question is a fool for five minutes;
he who does not ask a question remains a fool forever"
Jul 17 '05 #2
I noticed that Message-ID: <42*********************@news.xs4all.nl> from
Hans van Kranenburg contained the following:
Change or extend your local configuration so that it reflects the
configuration at the remote server.

An easy way is creating a virtual host on your local box with a
documentroot pointing to the wannabe /...


Any idea where I might find instructions on how to do that?

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #3
Geoff Berrow wrote:
If I'm working on a project, I'll usually create a folder to contain all the project files before uploading this to the root of the production
server. The trouble is that if I do:
include('/myfile.php')
this looks at the root of local host, as it should and not at the root of the working directory. It means that if I want to use absolute
links, I have to change them before I upload.
The quick solution is to use relative path (something like
.../foo.php or ./foo.php). But, if we use relative path for all
includes, it will hit performance. So, I use something like:

<?php
//config.inc.php
$CFG['project_path'] = '/home/foo/foo/';
//etc etc
?>

<?php
//foo.php
require_once('../common/config.inc.php'); //relative to project
require_once($CFG['project_path'] . 'html/header.html'); //absolute
//etc etc...
require_once($CFG['project_path'] . 'html/footer.html'); //absolute
?>

As seen, only one path is relative. I even have a mechanism to auto
detect the project path in config.inc.php.
I'm pretty sure this has been done before (FAQ entry material?), but not for a while. :-)


Yes, this has to be included in FAQ. But, what could be an
appropriate question?

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

Jul 17 '05 #4

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

Similar topics

3
by: Brian van den Broek | last post by:
Hi all, I'm just starting to employ unit testing (I'm using doctest), and I am uncertain how to handle writing tests where the behaviour being tested is dependant on whether certain file paths...
2
by: jordan | last post by:
I'm using the Server.Execute method to include a static page inside a dynamic database call. This static page is not a valid HTML page (i.e. lacking <body>,<head>, etc. elements), but I'm pulling...
2
by: shruti | last post by:
hiii all I'm tryin to call a perl script from a C program in following 2 ways- 1.By callin system function. But there's some problem because the system function is not able to executeany...
1
by: shruti | last post by:
hiii all I'm tryin to call a perl script from a C program in following 2 ways- 1.By callin system function. But there's some problem because the system function is not able to executeany...
1
by: Martin Mücke | last post by:
I got a website consisting of about 150 php pages. The site uses a frameless table based design. Header and menu are always the same and therefore should be extracted. At the moment I got a...
12
by: duzhidian | last post by:
failed to open stream: No such file or directory I have the programs like this structure: a.php is locate at . b.php is located at ./lib c.php is located at ./lib/sublib a.php uses a...
3
by: Alexander Vasilevsky | last post by:
Here, there is a challenge: to find the files must be on a local computer, have the same names. Get drives and folders to go through without problems. But what and how to store files while a...
10
by: kimiraikkonen | last post by:
Hi, I have an app which has a listbox and when i double click an associated fileS, i want their paths to be added into listbox in my application. This code works good when i try to open a...
0
by: VigneshS | last post by:
Hi, I am a newbie to Globalization and Localisation Concepts. I tried almost all the methods of the Globalization concepts. But i cannot be able to embed a text file within a Resource. ...
12
by: Hongyu | last post by:
Dear all: I am trying to write to a file with full directory name and file name specified (./outdir/mytestout.txt where . is the current directory) in C programming language and under Unix, but...
0
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.