473,785 Members | 2,736 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 011000100110110 0010000000110
001101101011011 001000110111101 100111001011
100110001101101 111001011100111 010101101011
Jul 17 '05 #1
3 1413
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
configuratio n 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($C FG['project_path'] . 'html/header.html'); //absolute
//etc etc...
require_once($C FG['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
1294
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 point to actual files. I have a class which takes, in its __init__, a list of file paths to process. The class has a method to validate that the paths passed in are appropriate ones for the class. One portion of the validation code ensures that...
2
1936
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 it into the dynamic page just to give the content an upgrade in presentation, including images. The problem is that there is no way to have relative URLs in the content page, so all the image src's are wrong. Is there a better way to include...
2
3504
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 command...it just returns -1. 2.By using the code given in perldoc perlembed(perl documentation for embedding perl in C)
1
1690
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 command...it just returns -1. 2.By using the code given in perldoc perlembed(perl documentation for embedding perl in C)
1
1757
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 "frame" (not a real html frame, more like "framework"), that contains my menu and header content. In this php page I dynamically include all content pages. Downsides: All pages got the same meta tags. Now I am looking for a better solution. I...
12
1746
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 function at b.php while b.php using a function at c.php
3
2328
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 search? http://www.alvas.net - Audio tools for C# and VB.Net developers + Christmas gift
10
3690
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 "single" file with my app which works to get commandline arguments to get file paths: Dim cla As String() = Environment.GetCommandLineArgs() If cla.Length 1 Then
0
1554
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. My need is to open a solution programmatically, select a Project within, and get a source resource file. Then, select a number of cultures and create culture specific resources with the content of the source resource assembly. I aquired upto...
12
8544
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 got errors of Failed to open file ./outdir/mytestout.txt. Below is the code: #include <stdio.h> int main(void)
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10319
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
10087
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,...
1
7496
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
6737
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
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4046
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
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2877
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.